CodeIgniter、Active Record 还是查询生成器?
CodeIgniter, Active Record or Query Builder?
我对 CI 中的 Active Record(AR) 不太了解,因为我在 Ruby 中比较了它 Rails,根据 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. It is an implementation of the Active Record pattern which itself is a description of an Object Relational Mapping system.
例如 CI
中的 AR
$query = $this->db->get('mytable');
它看起来更像是查询生成器而不是 AR,请解释一下,因为我几周前才开始使用 CI。
Codeigniter 活动记录
CodeIgniter 使用 Active Record 数据库模式的修改版本。此模式允许使用最少的脚本在数据库中检索、插入和更新信息。在某些情况下,执行数据库操作只需要一两行代码。 CodeIgniter 不要求每个数据库 table 都是它自己的 class 文件。相反,它提供了一个更简化的界面。
变更日志版本 3.0.0:(2015 年 3 月 30 日)
Renamed the Active Record class to Query Builder to remove confusion with the Active Record design pattern.
关于 Codeigniter 中的活动记录在维基百科上:
CodeIgniter 有一个它称为 "ActiveRecord" 的查询构建器,但它没有实现 Active Record 模式。相反,它实现了用户指南所指的模式的修改版本。 CodeIgniter 中的 Active Record 功能可以通过使用 CodeIgniter DataMapper 库或 CodeIgniter Gas ORM 库来实现。
我对 CI 中的 Active Record(AR) 不太了解,因为我在 Ruby 中比较了它 Rails,根据 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. It is an implementation of the Active Record pattern which itself is a description of an Object Relational Mapping system.
例如 CI
中的 AR$query = $this->db->get('mytable');
它看起来更像是查询生成器而不是 AR,请解释一下,因为我几周前才开始使用 CI。
Codeigniter 活动记录
CodeIgniter 使用 Active Record 数据库模式的修改版本。此模式允许使用最少的脚本在数据库中检索、插入和更新信息。在某些情况下,执行数据库操作只需要一两行代码。 CodeIgniter 不要求每个数据库 table 都是它自己的 class 文件。相反,它提供了一个更简化的界面。
变更日志版本 3.0.0:(2015 年 3 月 30 日)
Renamed the Active Record class to Query Builder to remove confusion with the Active Record design pattern.
关于 Codeigniter 中的活动记录在维基百科上:
CodeIgniter 有一个它称为 "ActiveRecord" 的查询构建器,但它没有实现 Active Record 模式。相反,它实现了用户指南所指的模式的修改版本。 CodeIgniter 中的 Active Record 功能可以通过使用 CodeIgniter DataMapper 库或 CodeIgniter Gas ORM 库来实现。