Is it possible to UNLOAD a model? |
[eluser]jwright[/eluser]
Hi Aken, You can see the reason I needed to replace a model here in the constructor of this class https://github.com/wrightlabs/tank_auth_...groups.php . The class I replaced the model with, inherited from the class of the original model object. In most normal circumstances, you're right, there would be no reason to replace a model object once loaded. In this case, I had the goal of not touching any existing code, so inheritance and replacing the model object helped me achieve this goal. As far as unloading, my main concern is not with CodeIgniter. But once you load a php file with "require" (or similar), if that php file has a class declaration in it, I'm not sure how to "unload" that class declaration from that specific run of the php interpreter (for that page view). While it might be possible (if it is I'm sure it's in the php docs somewhere), I'm not aware how to do it. What made me aware of this issue is an error you will get that says something like "cannot re-declare class 'My_model'" . This can happen if a file (containing a class declaration) has already been loaded and unloaded from CodeIgniter, and you try to load it again or a class with the same name. So unloading can be more tricky than it sounds. I imagine this is why there is no official unload method in CodeIgniter itself. UPDATE: After some searching, I wasn't able to find anything in the PHP Docs concerning unloading classes. But I did see a few responses on stackoverflow.com that stated "It's not possible to unload a class from PHP". So from the best I can tell, it's not possible. If anyone finds a way to unload a class from PHP (which CodeIgniter is built on), I'd be interested to know. |
Messages In This Thread |
Is it possible to UNLOAD a model? - by El Forum - 11-16-2007, 10:38 AM
Is it possible to UNLOAD a model? - by El Forum - 11-16-2007, 11:51 AM
Is it possible to UNLOAD a model? - by El Forum - 11-16-2007, 12:44 PM
Is it possible to UNLOAD a model? - by El Forum - 11-17-2007, 03:59 AM
Is it possible to UNLOAD a model? - by El Forum - 04-01-2009, 10:01 AM
Is it possible to UNLOAD a model? - by El Forum - 10-17-2009, 11:02 PM
Is it possible to UNLOAD a model? - by El Forum - 10-18-2009, 07:17 AM
Is it possible to UNLOAD a model? - by El Forum - 02-17-2012, 06:42 PM
Is it possible to UNLOAD a model? - by El Forum - 02-18-2012, 02:53 AM
Is it possible to UNLOAD a model? - by El Forum - 02-20-2012, 12:12 PM
Is it possible to UNLOAD a model? - by El Forum - 02-20-2012, 01:00 PM
Is it possible to UNLOAD a model? - by El Forum - 07-12-2013, 07:08 PM
Is it possible to UNLOAD a model? - by El Forum - 07-31-2013, 09:21 PM
Is it possible to UNLOAD a model? - by El Forum - 07-31-2013, 09:37 PM
|