With traditional OOP, i would (or could, rather) create a model / object that represents a User
, with properties that reflect that, i.e. name
, id
, job title
etc.
I could then create a new instance of that object and assign it to a variable, and if i was looping through a result set, i could create an instance for each one. With codeigniter, this seems impossible, as doing:
$this->load->model('User');
Instantiates it, and places it for use at $this->user
.
Is there no way to use models as objects in a more traditional manner?, but without hacking the CI way of doing things?
I understand that you can assign things to a different object name using $this->load->model('User', 'fubar')
, but it's not as dynamic as simply assigning an instance to a variable.
Any insight into the matter is greatly appreciated guys.
EDIT: thanks for the answers guys, i think that i missed a vital part of working the "Codigniter Way", but i've just been looking through a contributed library, and the practice of using the same instance (assigned to the codeigniter namespace) but clearing the instance variables after each use, seems to be a great way to work that removes my reservations.
Once again - thanks for the help and answers.