CodeIgniter, models, and ORM, how to deal with this? CodeIgniter, models, and ORM, how to deal with this? codeigniter codeigniter

CodeIgniter, models, and ORM, how to deal with this?


You probably want something like this:

   class Cars {    //List all neccessary vars here    function __construct() {        //get instance of Codeigniter Object and load database library        $this->obj =& get_instance();        $this->obj->load->database();    }//You can now list methods like so:function selectCar($name, $color) {        $this->obj->db->select('color')->from('car')->where('color', $color);        $query = $this->obj->db->get();        switch ($query->num_rows()) {        case 0:            return false;            break;        default:            return $query->result();            break;        }    }

Hope that helps!


Try with Doctrine, is a great ORM and can be easily integrated in CodeIgniter.


take a look the the codeigniter wiki page for ORM

http://codeigniter.com/wiki/ORM/