简体   繁体   English

cakephp v3.x中的存储库和表对象有什么区别?

[英]What is the difference between repositories and table objects in cakephp v3.x?

I have been using Cakephp ver2.x and just started migrating to Cakephp v3.x. 我一直在使用Cakephp ver2.x,并且刚开始迁移到Cakephpv3.x。 When I tried using the new ORM, I am baffled by basic concepts like repositories and table objects. 当我尝试使用新的ORM时,我对诸如存储库和表对象之类的基本概念感到困惑。 What is the difference between repositories and table objects? 存储库和表对象有什么区别?

A repository can be anything while a table, as the name states, is just a table. 顾名思义,表可以只是表,而存储库可以是任何东西。

http://api.cakephp.org/3.0/class-Cake.ORM.Table.html http://api.cakephp.org/3.0/class-Cake.ORM.Table.html

Represents a single database table. 代表一个数据库表。

Exposes methods for retrieving data out of it, and manages the associations this table has to other tables. 公开从中检索数据的方法,并管理该表与其他表的关联。 Multiple instances of this class can be created for the same database table with different aliases, this allows you to address your database structure in a richer and more expressive way. 可以为具有不同别名的同一个数据库表创建此类的多个实例,这使您能够以更丰富和更具表达力的方式处理数据库结构。

http://api.cakephp.org/3.0/class-Cake.Datasource.RepositoryInterface.html http://api.cakephp.org/3.0/class-Cake.Datasource.RepositoryInterface.html

Describes the methods that any class representing a data storage should comply with. 描述表示数据存储的任何类应遵循的方法。

A data storage can be any kind of storage system, even one that doesn't know tables like a graph DB or document based system. 数据存储可以是任何类型的存储系统,甚至是不知道表(例如图形数据库或基于文档的系统)的存储系统。

It is always simple to just check the API documentation and code for this kind of questions. 仅需检查API文档和代码中的此类问题,总是很简单。 The code is pretty well documented. 该代码已被很好地记录。 Also the way this works becomes obvious then: 然后,这种工作方式也变得显而易见:

class Table implements RepositoryInterface, EventListenerInterface

Table implements the interface defined by RepositoryInterface. 表实现了RepositoryInterface定义的接口。

暂无
暂无

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

相关问题 使用CakePHP v3.x和Composer自动加载供应商 - Autoload Vendor with CakePHP v3.x and Composer CakePHP v3.x如何在没有数据库连接的情况下进行烘焙 - CakePHP v3.x how to bake without database connection 我有一个网站进入cackephp v1.3.14,我想升级到cakephp v3.x - I have a website into cackephp v1.3.14 and i want to upgrade into cakephp v3.x CakePHP 2.x插件和插件文件夹之间有什么区别? - What's the difference between the CakePHP 2.x Plugin and plugins folders? 如何连接到在Cake php v3.x中在salesforce中作为自定义字段创建的Heroku Connect的表 - How to connect to Heroku connect's table that is created as custom field in salesforce in cake php v3.x 如何在openshift v3.x上创建配置和解聚PHP应用程序 - how to create configure and depoly Php app on openshift v3.x cakephp 3.x 中的 index.ctp 和 view.ctp 有什么区别? - what is the difference between index.ctp and view.ctp in cakephp 3.x? 在CakePHP 3.0中,initialize()和beforeFilter()有什么区别? - In CakePHP 3.0 what is the difference between initialize() and beforeFilter()? CakePHP 2中的generate()方法和新的ControllerTestCase类之间有什么区别? - What's the difference between the `generate()` method and the new ControllerTestCase class in CakePHP 2? JsonResource 和 ResourceCollection 有什么区别? 在 Laravel v6 或 v7 中 - What is the difference between a JsonResource & ResourceCollection? in Laravel v6 or v7
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM