How can I use proper object-oriented models in CodeIgniter with constructors?
You can do it like you normally would:
require_once(APPPATH.'models/User.php');$User = new User($userID);
Or, you can rely on a table-level model to return a record-level model:
$this->load->model('users_model'); // users (plural) is the table-level model$User = $this->users_model->get_user($userID);
Meanwhile, in users_model
require_once(APPPATH.'models/User.php');public function get_user($userID){ // get a record from the db // map record to model // return model}
you can subclass
the model or just add something in the constructor
I think you need to adjust code to do it the way you're looking to…