Last Modified: 01.10.2018
ORM (Object-relational mapping) is a programming technique that connects databases with the concepts of object-oriented programming languages creating a "virtual object database" (Wikipedia).
In the old core, its own GetList, Update, Add, and Delete are programmed for each entity.
Deficiencies of such method:
Purposes in the New Core:
- Different set of parameters;
- Different syntax of the filter fields;
- Events may be existent or non-existent;
- Sometimes different code for different databases (
To make database selecting and saving operations uniform with the same parameters and filters. If possible, entity tables must be serviced with a minimum of a new code. Standard events of adding/changing/deleting must be available automatically.
The following notions were introduced to implement these purposes:
- Entities (Bitrix\Main\Entity\Base).
- Entity fields (Bitrix\Main\Entity\Field and its successors).
- Data manager (Bitrix\Main\Entity\DataManager).
An entity describes a table in the database, and also contains entity fields. The DataManager performs selection and entity change operations. In practice, the work is mostly done at the level of the DataManager.
Note: This chapter provides abstract examples for purposes of clarification. Using the provided examples via copy\paste may not render the desired result for your specific project. Examples must be adapted for your specific code and database structure.