31,016
edits
| Line 349: | Line 349: | ||
There is 3 way to make links: | There is 3 way 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 a the table. The class contains only code to reach lines and fields of table. | 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 a the table. The class contains only code to reach lines and fields of table. | ||
| Line 360: | Line 361: | ||
* The '''Data Mapper''' | * The '''Data Mapper''' | ||
Classes represent entities of the problem and not the data. So you have to double, triple ... theese 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. | |||
Example: This is the choice if you use the ORM Framework'' 'Propel''' (http://propel.phpdb.org/trac/). We find this model on heavier applications, based on this ORM among others. | |||
-> | -> For Dolibarr development, it is recommended to use the connection mode '''Active Record''', which offers the advantages of a model close to the business without having the complexity, without obfuscating the technique. It is in this way that the development, understanding of code and technical maintenance and / or business seems the more productive (this is however an ongoing debate between the purists and the pragmatists, debate in which nobody can really be right, because it depends on the objectives). | ||