简体   繁体   English

CodeIgniter,Active Record或查询生成器?

[英]CodeIgniter, Active Record or Query Builder?

I got little confuse for Active Record(AR) in CI, since I compare it in Ruby On Rails, according to Rails guide, Active Record means 我对CI中的Active Record(AR)没什么困惑,因为根据Rails指南,我在Ruby On Rails中进行了比较,Active Record的意思是

the layer of the system responsible for representing business data and logic. 负责表示业务数据和逻辑的系统层。 Active Record facilitates the creation and use of business objects whose data requires persistent storage to a database . Active Record有助于创建和使用业务对象,这些业务对象的数据需要持久存储到数据库中 It is an implementation of the Active Record pattern which itself is a description of an Object Relational Mapping system. 它是Active Record模式的实现,Active Record模式本身是对象关系映射系统的描述。

For example of AR in CI 例如CI中的AR

$query = $this->db->get('mytable');

it looks more like query builder than AR, please some explain since I just start use CI just few weeks ago. 它看起来更像是查询生成器而不是AR,请解释一下,因为我几周前才开始使用CI。

Codeigniter Active record Codeigniter活动记录

CodeIgniter uses a modified version of the Active Record Database Pattern. CodeIgniter使用Active Record数据库模式的修改版本。 This pattern allows information to be retrieved, inserted, and updated in your database with minimal scripting. 这种模式允许以最少的脚本在数据库中检索,插入和更新信息。 In some cases only one or two lines of code are necessary to perform a database action. 在某些情况下,只需一行或两行代码即可执行数据库操作。 CodeIgniter does not require that each database table be its own class file. CodeIgniter不需要每个数据库表都是其自己的类文件。 It instead provides a more simplified interface. 相反,它提供了更简化的界面。

Refer this 推荐这个

Changelog version 3.0.0: (March 30, 2015) Changelog版本3.0.0:(2015年3月30日)

Renamed the Active Record class to Query Builder to remove confusion with the Active Record design pattern. 将Active Record类重命名为Query Builder,以消除与Active Record设计模式的混淆。

About Active record in Codeigniter is on Wikipedia: 关于Codeigniter中的有效记录在Wikipedia上:

CodeIgniter has a query builder it calls "ActiveRecord", but which does not implement the Active Record pattern. CodeIgniter有一个查询生成器,它称为“ ActiveRecord”,但未实现Active Record模式。 Instead, it implements what the user guide refers to as a modified version of the pattern. 相反,它实现了用户指南所说的模式的修改版本。 The Active Record functionality in CodeIgniter can be achieved by using either CodeIgniter DataMapper library or CodeIgniter Gas ORM library. 通过使用CodeIgniter DataMapper库或CodeIgniter Gas ORM库,可以实现CodeIgniter中的Active Record功能。

https://en.wikipedia.org/wiki/Active_record_pattern https://zh.wikipedia.org/wiki/Active_record_pattern

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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