Welcome Guest, Not a member yet? Register   Sign In
ActiveRecord for CodeIgniter: Rails-style model interactions
#89

[eluser]webthink[/eluser]
are you sure you don't you want $pages = $this->page->count_texts()->find_all(); ?
I'm not really sure what your requirements are but if you're looking for number of pages I would suggest counting the rows returned from $this->page->find_all().
Using count_pages in the way you have doesn't make a lot of sense as you are already searching pages so it might try to join pages to pages. That construct should be used to count related records which is why I suggest that perhaps you want count_texts. Also unless $page->num_pages is actually a field in your pages table there isn't going to be any data there as I believe count would name the field like texts_count or pages_count. Try doing a var dump on $page to have a look what's in there. $this->db->last_query() is a useful tool as well to make sure active record is generating the sql you expect.
Perhaps you could tell us what it is you'd like to achieve in the query.

Cheers


Messages In This Thread
ActiveRecord for CodeIgniter: Rails-style model interactions - by El Forum - 02-28-2008, 01:53 AM



Theme © iAndrew 2016 - Forum software by © MyBB