304
edits
| Line 421: | Line 421: | ||
=== Communication between business logic - data (ORM) === | === Communication between business logic - data (ORM) === | ||
There | There are 3 ways to make links: | ||
* The '''Table And Row Data Gateway''' | * The '''Table And Row Data Gateway''' | ||
This is the most simple. You have one class per table and each class is a link to the table with CRUD methods (Ceate, Read, Update, Delete). A class instance is a record | This is the most simple. You have one class per table and each class is a link to the table with CRUD methods (Ceate, Read, Update, Delete). A class instance is a record in the table. The class contains only code to reach lines and fields of table. | ||
Example: This mode is used by some ORM Frameworks, like '''iBatis''' (http://ibatis.apache.org/). | Example: This mode is used by some ORM Frameworks, like '''iBatis''' (http://ibatis.apache.org/). | ||
* The '''Active Record''' | * The '''Active Record''' | ||
Same | Same as previous, but we are allowed to add some business functions into the class, if such functions are dedicated to the table or recording into this table. | ||
Example: This mode is used for Dolibarr development and most PHP softwares that | Example: This mode is used for Dolibarr development and most PHP softwares that include their own framework and best practices. | ||
* The '''Data Mapper''' | * The '''Data Mapper''' | ||
Classes represent entities of the problem and not the data. So you have to double, triple ... | Classes represent entities of the problem and not the data. So you have to double, triple ... these classes with Mapper classes to access the data. | ||
More "purist" on paper (closer of business), this method also has the disadvantage of being more complex in practice. | More "purist" on paper (closer of business), this method also has the disadvantage of being more complex in practice. | ||
edits