CodeIgniter Forums

Full Version: Adding where clause to count_all
You're currently viewing a stripped down version of our content. View the full version with proper formatting.

El Forum

[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.

El Forum

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

El Forum

[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/