且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

CodeIgniter Framework中的库和模型有什么区别?

更新时间:2023-12-03 11:56:52

对此可能还有其他流派,但对我来说,如下:

There are probably other schools of thought on this, but for me it's as follows:

模型与应用程序紧密耦合,直接引用数据库模式/体系结构/文件路径等。

Models are tightly coupled to your application, making direct references to your DB schema/architecture/file paths etc.

图书馆是松散耦合的。它们应被视为第三方添加物,并且不应对您的应用或系统做任何假设。您应该能够以最少的配置随意插入库。确实,事实恰恰相反,您的库文件夹中的项目应该能够放入任何其他CI应用程序中。

Libraries are loosely coupled. They should be treated like 3rd party add-ons and should make no assumptions about your app or your system. You should be able to "drop in" libraries at will with a minimum amount of configuration. Indeed, the opposite should be true, items in your library folder should be able to be dropped into any other CI application.