Not to load an autoload library in codeigniter

心不动则不痛 提交于 2019-12-02 18:28:32

问题


I have a library which is used by all controllers. But for a specific controller i dont want to load that library. Is there any way i can stop loading that library for that controller.

i am using this command but its failing:
$this->load->library('xyz',array('autoload' => FALSE));

Thanks


回答1:


Autoloading is meant for site-global items.

A cleaner solution may be to extend the controller and load the library in that new controller's constructor. Then all of your controllers extend from that controller, except the one(s) you don't want to load that library - those can extend the original CI controller.

That should take you < 5 minutes to implement and you won't have to hack anything.




回答2:


You can take a look at this link:

http://xplus3.net/2010/05/31/conditional-auto-loading-of-libraries-in-codeigniter/

Basically, you'd be overwriting the autoload.php library to check for a variable. If that variable is false, then explicitly add the specific library to the autoload array.



来源:https://stackoverflow.com/questions/8096630/not-to-load-an-autoload-library-in-codeigniter

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!