duandou9931 2015-05-08 09:15
浏览 30
已采纳

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

I have been using Cakephp ver2.x and just started migrating to Cakephp v3.x. When I tried using the new ORM, I am baffled by basic concepts like repositories and table objects. What is the difference between repositories and table objects?

  • 写回答

1条回答 默认 最新

  • dsjbest2015 2015-05-08 09:24
    关注

    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

    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

    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. 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.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥25 由IPR导致的DRIVER_POWER_STATE_FAILURE蓝屏
  • ¥50 有数据,怎么建立模型求影响全要素生产率的因素
  • ¥50 有数据,怎么用matlab求全要素生产率
  • ¥15 TI的insta-spin例程
  • ¥15 完成下列问题完成下列问题
  • ¥15 C#算法问题, 不知道怎么处理这个数据的转换
  • ¥15 YoloV5 第三方库的版本对照问题
  • ¥15 请完成下列相关问题!
  • ¥15 drone 推送镜像时候 purge: true 推送完毕后没有删除对应的镜像,手动拷贝到服务器执行结果正确在样才能让指令自动执行成功删除对应镜像,如何解决?
  • ¥15 求daily translation(DT)偏差订正方法的代码