CodeIgniter Forums
Adding where clause to count_all - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forum-20.html)
+--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forum-23.html)
+--- Thread: Adding where clause to count_all (/thread-43737.html)



Adding where clause to count_all - El Forum - 07-21-2011

[eluser]Wonder Woman[/eluser]
Hi,

I basically just want to add a where clause to my count all request - is there anyway I can add this on to what I have?

I currently have:
Code:
$this->db->count_all('comments');

but I would typically like:
Code:
$this->db->count_all('comments')->where('approved', 1);

or something similar.

Any help would be appreciated.

Thanks.


Adding where clause to count_all - El Forum - 07-22-2011

[eluser]toopay[/eluser]
Code:
$this->db->where('foo', 'bar');
$this->db->from('some_table');
echo $this->db->count_all_results();



Adding where clause to count_all - El Forum - 07-22-2011

[eluser]Wondering Coder[/eluser]
toopay, could you help me about my problem in my query too
this is the link: http://ellislab.com/forums/viewthread/194401/