CodeIgniter Forums
How do you reset an object - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20)
+--- Forum: Archived General Discussion (https://forum.codeigniter.com/forumdisplay.php?fid=21)
+--- Thread: How do you reset an object (/showthread.php?tid=8844)



How do you reset an object - El Forum - 06-02-2008

[eluser]floweringmind88[/eluser]
I loaded a class from my library. It works great but then the second time I call the object function it spits out the old data instead of the new data.

Is there a way to reset the class object?

Thanks!
Chris


How do you reset an object - El Forum - 06-03-2008

[eluser]stuffradio[/eluser]
Wouldn't you just use the unset($object); function?


How do you reset an object - El Forum - 06-03-2008

[eluser]Kromack[/eluser]
Do a new Object of your class ?


How do you reset an object - El Forum - 06-03-2008

[eluser]floweringmind88[/eluser]
The real problem was arrays were not being cleared in the class so the next time I used it the old data was spit out. So everything is great now.


How do you reset an object - El Forum - 06-04-2008

[eluser]nmweb[/eluser]
Code:
new ClassName;

After you do $this->load, the class file is included so you can always instantiate new classes of the kind afterwards.