Welcome Guest, Not a member yet? Register   Sign In
How can I get multiple instance of class?
#1

[eluser]Unknown[/eluser]
How can I get multiple instance of class?
#2

[eluser]tonanbarbarian[/eluser]
if you are talking about multiple instances of a library then load the library the first time, which loads the class file, then create as many other instances as you need
Code:
...
$this->load->library('mylib');
// use the original instance of mylib
$this->mylib->something();
// create another instance
$this->anothermylib =& new MyLib();
$this->anothermylib->something();
...

You should also be able to do something similar with model, but not sure about controllers
#3

[eluser]Grahack[/eluser]
If you're talking about a model...

From the docs:

Quote:If you would like your model assigned to a different object name you can specify it via the second parameter of the loading function:
Code:
$this->load->model('Model_name', 'fubar');

$this->fubar->function();




Theme © iAndrew 2016 - Forum software by © MyBB