Skip to main content
page last edited on 10 October 2022

Database

Version: 5.5.0

To work with the database, Doctrine ORM is used:

https://www.doctrine-project.org/projects/doctrine-orm/en/2.13/index.html

In this case, X-Cart uses the corresponding symfony service https://symfony.com/doc/5.4/doctrine.html

For modules, if there is a folder <XCart>/modules/{AuthorId}/{ModuleId}/src/Model, model search in this folder is automatically configured. Repositories are selected from the folder <XCart>/modules/{AuthorId}/{ModuleId}/src/Model/Repo.

The actual work with the database is carried out within the framework of the repositories.

For symfony compatible code, you can refer to the symfony documentation.

For X-Cart code, to get the EntityManager object and the repository, you need to use the following constructs:

$entityManager = \XLite\Core\Database::getEM();

$repo = \XLite\Core\Database::getRepo({ModelFQCN});
# or
$repo = \XLite\Core\Database::getEM()->getRepository({ModelFQCN});

In other aspects, you should use the symfony and doctrine documentation as well.