CodeIgniter Forums
retriving value from database with get_where - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20)
+--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forumdisplay.php?fid=23)
+--- Thread: retriving value from database with get_where (/showthread.php?tid=32647)



retriving value from database with get_where - El Forum - 07-29-2010

[eluser]jonyork[/eluser]
Alright Im trying to retrive the number of rows where members are individual and active.

Ive narrowed the problem to my model. Everything was working fine until I added a second clause to my get_where

Here is my model function

Code:
function count_individual_active_members()
    {
        $query = $this->db->get_where('Membership', array('Membership_Status' => 'Active', 'Membership_cat' => 'Individual'));
        return $query->num_rows();
    }

What and I doing wrong, and how can I fix it?

thanks


retriving value from database with get_where - El Forum - 07-29-2010

[eluser]jonyork[/eluser]
Sorry guys,

fixed it on my own Big Grin

Code:
function count_individual_active_members()
    {
        $query = $this->db->where(array('Membership_Status' => 'Active', 'Membership_Cat' => 'Individual'));
        $query = $this->db->get('Membership');
        return $query->num_rows();
    }



retriving value from database with get_where - El Forum - 07-30-2010

[eluser]WanWizard[/eluser]
That's odd, because that is exactly what get_where() does.

Can you humor me, and do a echo $this->db->last_query() for both solutions, and see if there are any differences? If this is a bug than it needs to be reported.