Welcome Guest, Not a member yet? Register   Sign In
Active record WHERE clause not working?
#13

[eluser]xarazar[/eluser]
Just to clarify this is the exact setup of my app:

Code:
class Site extends CI_Controller{
    function index(){
        $this->output->enable_profiler(TRUE);
        $q = $this->db->where('url', 'home');
        $q = $this->db->get('content');
        print_r($q->result());
    }
}
The above works as expected, prints out one record from the database, the profiler shows the executed query.

When I change the setup to:

Code:
class Site extends CI_Controller{
    function index(){
        $this->output->enable_profiler(TRUE);
        print_r($this->site_model->get_page('home'));
    }
}


class Site_model extends CI_Model{
    
    function get_page($url = 'home'){
        $q = $this->db->where('url',  $url);
        $q = $this->db->get('content');
        return $q->result();
    }
}

The script prints out all the records from the table = the WHERE clause doesn't work.

When I modify my model to use get_where like this:
Code:
class Site_model extends CI_Model{
    function get_page($url = 'home'){
        $q = $this->db->get_where('content',  array('url' => $url));
        return $q->result();
    }
}

everything seems to be working fine.

I'm this close to going back to CI 1.7.3 so any help or suggestions will be greatly appreciated.


Messages In This Thread
Active record WHERE clause not working? - by El Forum - 03-08-2011, 09:27 AM
Active record WHERE clause not working? - by El Forum - 03-08-2011, 09:41 AM
Active record WHERE clause not working? - by El Forum - 03-08-2011, 09:43 AM
Active record WHERE clause not working? - by El Forum - 03-08-2011, 09:45 AM
Active record WHERE clause not working? - by El Forum - 03-08-2011, 09:49 AM
Active record WHERE clause not working? - by El Forum - 03-08-2011, 10:02 AM
Active record WHERE clause not working? - by El Forum - 03-08-2011, 10:13 AM
Active record WHERE clause not working? - by El Forum - 03-08-2011, 10:27 AM
Active record WHERE clause not working? - by El Forum - 03-08-2011, 10:38 AM
Active record WHERE clause not working? - by El Forum - 03-08-2011, 10:51 AM
Active record WHERE clause not working? - by El Forum - 03-08-2011, 12:09 PM
Active record WHERE clause not working? - by El Forum - 03-08-2011, 03:37 PM
Active record WHERE clause not working? - by El Forum - 03-09-2011, 04:03 AM
Active record WHERE clause not working? - by El Forum - 03-09-2011, 04:51 AM
Active record WHERE clause not working? - by El Forum - 03-09-2011, 05:00 AM
Active record WHERE clause not working? - by El Forum - 03-09-2011, 05:46 AM
Active record WHERE clause not working? - by El Forum - 03-09-2011, 05:54 AM
Active record WHERE clause not working? - by El Forum - 03-09-2011, 05:55 AM
Active record WHERE clause not working? - by El Forum - 03-09-2011, 05:56 AM
Active record WHERE clause not working? - by El Forum - 03-09-2011, 06:04 AM
Active record WHERE clause not working? - by El Forum - 03-09-2011, 06:12 AM
Active record WHERE clause not working? - by El Forum - 03-09-2011, 06:34 AM
Active record WHERE clause not working? - by El Forum - 03-09-2011, 06:39 AM
Active record WHERE clause not working? - by El Forum - 03-09-2011, 06:47 AM
Active record WHERE clause not working? - by El Forum - 03-09-2011, 09:41 AM
Active record WHERE clause not working? - by El Forum - 03-09-2011, 05:41 PM
Active record WHERE clause not working? - by El Forum - 03-09-2011, 06:17 PM
Active record WHERE clause not working? - by El Forum - 03-09-2011, 06:23 PM
Active record WHERE clause not working? - by El Forum - 05-12-2011, 03:03 AM



Theme © iAndrew 2016 - Forum software by © MyBB