[eluser]malcomhfc[/eluser]
Hi, i need some help with getting the number of rows where a certain value is true.
I have managed to do it for one call. However i need the where value to have different params.
For example.
if username = bob then count number of rows and return.
if password = banana then count number of rows and return.
This is what i have in the model so far
Code:
public function count_by($params = array())
{
if ($params['status'] == 'open')
{
$this->db->where('status', $params['status']);
}
return $this->db->count_all_results('dev');
}
The above i need to check for status = draft and status = closed also.
the controller:
Code:
$status = $this->dev_m->count_by(array('status' => 'open'));
The view i just echo status. But im looking for a way to something along the lines of
Code:
echo status->open; echo status->closed;
I'm learning PHP and i don't want to make a variable for every count in the controller.
Any suggestions would be greatly appreciated.