Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is the difference between a table and entity in the context of Model in cakephp v3.x and what kind of code goes in?

In cakephp v3.x, the Model folder contains 3 folders - Behavior, Entity, Table. I am confused over what kind of code should I put in the Entity and Table files.

Should code related to retrieving data and resultsets be all be placed in the Table files? If yes, what sort of code should one place in the Entity files?

like image 836
guagay_wk Avatar asked Feb 10 '23 04:02

guagay_wk


1 Answers

According to the cakephp 3.0 manual, the Model layer has been re-written and replaced. Consider reading the ORM Migration in order to understand the differences better.

Cake\ORM\Table - The main entry point into the new ORM. Provides access to a single table. Handles the definition of association, use of behaviors and creation of entities and query objects.

Cake\ORM\Entity - Represents a single row result. Makes accessing data and serializing to various formats a snap.

like image 162
Ofir Baruch Avatar answered Feb 12 '23 18:02

Ofir Baruch