ORM/DAO/DataMapper/ActiveRecord/TableGateway 的区别?
能否请你解释一下以下数据库代表之间的区别,比如在 PHP 中.
ORM道数据映射器活动记录表格网关
如有任何示例,我们将不胜感激.
解决方案这需要一个很长的答案.我没有在我面前重复别人说得更好更详细的内容,而是将您链接到一些相关页面.我建议仔细查看它们.也许遵循一些额外的链接.维基百科总是一个好的开始.如果您在浏览链接后仍然对一种或另一种模式有任何疑问,请随时返回 SO 并再次提问.但是,如果您这样做了,请尝试缩小范围.提出多个问题并专注于特定方面比期望人们为您写文章要好.
对象关系映射器
<块引用>计算机软件中的对象关系映射(ORM、O/RM 和 O/R 映射)是一种编程技术,用于在关系数据库和面向对象的编程语言中不兼容的类型系统之间转换数据.
数据访问对象><块引用>
使用数据访问对象 (DAO) 来抽象和封装对数据源的所有访问.DAO 管理与数据源的连接以获取和存储数据.
DataMapper
<块引用>一层映射器 (473),用于在对象和数据库之间移动数据,同时保持它们彼此独立以及映射器本身.
活动记录
<块引用>在数据库表或视图中包装一行、封装数据库访问并在该数据上添加域逻辑的对象.
表数据网关
<块引用>充当数据库表网关 (466) 的对象.一个实例处理表中的所有行.
Can you, please, explain me the differences between the following database representatives, say, in PHP.:
ORM DAO DataMapper ActiveRecord TableGateway
Any examples would be appreciated.
解决方案That would require a pretty long answer. Instead of repeating what others have said better and in more detail before me, I link you to some relevant pages. I suggest to look through them. Maybe follow a few additional links. Wikipedia is always a good start. If you still have any questions about one or the other pattern after going through the links, feel free to come back to SO and ask again. But if you do, try to narrow it down. It's better to ask multiple questions and focus on particular aspects than expecting people to write an essay for you.
Object Relational Mapper
Object-relational mapping (ORM, O/RM, and O/R mapping) in computer software is a programming technique for converting data between incompatible type systems in relational databases and object-oriented programming languages.
Data Access Object
Use a Data Access Object (DAO) to abstract and encapsulate all access to the data source. The DAO manages the connection with the data source to obtain and store data.
DataMapper
A layer of Mappers (473) that moves data between objects and a database while keeping them independent of each other and the mapper itself.
Active Record
An object that wraps a row in a database table or view, encapsulates the database access, and adds domain logic on that data.
Table Data Gateway
An object that acts as a Gateway (466) to a database table. One instance handles all the rows in the table.
相关文章