I'd like to create several instances of a class in codeigniter.
I have created my class as a library, but cannot figure out the syntax to use to create more than 1 instance.
I'd like to create several instances of a class in codeigniter.
I have created my class as a library, but cannot figure out the syntax to use to create more than 1 instance.
From the CodeIgniter users guide:
Assigning a Library to a different object name
If the third (optional) parameter is blank, the library will usually be assigned to an object with the same name as the library. For example, if the library is named Session, it will be assigned to a variable named $this->session.
If you prefer to set your own class names you can pass its value to the third parameter: $this->load->library('session', '', 'my_session');
// Session class is now accessed using:
$this->my_session
I think that's what you're looking for.