The way I create CodeIgniter models at the moment is (i.e. no constructor, having to pass userID all the time and limited to one object):
$this->load->model('User');
$this->user->set_password($userID, $password);
But I would like to do it like this:
$this->load->model('User');
$User = new User($userID);
$User->set_password($password);
UPDATE: Perhaps just a user model was a poor example.
For instance, if I have a shopping list that has various items I would like to use PHP in this way:
$this->load->model('List');
$this->load->model('Item');
$List = new List();
$items[] = new Item($itemName1, $itemPrice1);
$items[] = new Item($itemName2, $itemPrice2);
$List->add_items($items);
CodeIgniter feels fundamentally broken in handling PHP OO in this way. Does anyone have any solutions that can still use the superobject within every model?
You can do it like you normally would:
Or, you can rely on a table-level model to return a record-level model:
Meanwhile, in
users_model