[eluser]asyafrudin[/eluser]
Hi.
I realized that if I wanted to use a 3rd party class in CodeIgniter, I have to use it as part of CodeIgniter's library. It happens that the class I'm using will be used inside a loop. Here's the snippet:
Code:
for ($i = 0; $i < some_number; $i++)
{
$obj = new Myclass();
//Codes using $obj ...
}
Knowing that loading a class in CodeIgniter means loading a library, the above code should look like this:
Code:
for ($i = 0; $i < some_number; $i++)
{
$this->load->library('Myclass');
//Codes using $this->myclass ...
}
But then I realize both code does not do the exact same thing. The first code will create a new instance of Myclass for each iteration, but it's not like that with the second code. It seems that in the second, the library will actually be loaded only in the first iteration.
The above results in unexpected behavior because I really need to load a new object for each iteration. Is there any way to make sure that the second code actually creates a new $this->myclass object?
Thanks for the help.