What is the difference between library and model in CodeIgniter Framework?

后端 未结 2 657
有刺的猬
有刺的猬 2021-02-14 15:22

I am new to CI. Before I had worked extensively in RoR and Symfony.

I am unable to understand why exactly CI provides Library and Models. Most of the CI code I examined

2条回答
  •  粉色の甜心
    2021-02-14 15:53

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

    Models

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

    Libraries

    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.

提交回复
热议问题