简体   繁体   中英

Is loading libraries within models in CodeIgniter a good idea?

I'm using a customly created MySQL input sanitization library in one of my controllers, which makes a mess, using it in the model would be much easier, but I don't wan't to defy any best-practice principles out there either. So is it a good idea?

I ran into this myself. You know what? If it makes your application work, screw conventions. If you need to call a chunk of code that you've already written (and you know it will work), then there's no good reason to follow "best-practices" and do something that will effectively make your app slower/less efficient/etc.

The whole point of best practices is to write code in the best way. If the best way that something seems like it should be done is by calling a library from a model, go for it. Best practices are not a universal law.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM