QuidPHP/Orm is a PHP library that provides database abstraction using PDO and an easy-to-use Object-Relational Mapper (ORM). It is part of the QuidPHP package and can also be used standalone.
QuidPHP/Orm is available as an open-source software under the MIT license.
QuidPHP/Orm documentation is available at QuidPHP/Docs.
QuidPHP/Orm can be easily installed with Composer. It is available on Packagist.
$ composer require quidphp/orm
Once installed, the Quid\Orm namespace will be available within your PHP application.
QuidPHP/Orm requires the following:
- PHP 8.1 with these extensions:
- PDO
- pdo_mysql
- Mysql (>= 8.0) or MariaDB (>= 10.4) database
- All requirements of quidphp/main
QuidPHP/Orm has the following dependency:
- quidphp/main - Quid\Main - PHP library that provides a set of base objects and collections
The dependency will be resolved by using the Composer installation process.
QuidPHP/Orm code is commented and all methods are explained (in French).
QuidPHP/Orm is built on the following conventions:
- Coding: No curly braces are used in a IF statement if the condition can be resolved in only one statement.
- Config: A special $config static property exists in all classes. This property gets recursively merged with the parents' property on initialization.
- Dynamic singleton: Table, Col, Row and Cell objects can only exist once for a same source.
- Traits: Traits filenames start with an underscore (_).
- Type: Files, function arguments and return types are strict typed.
QuidPHP/Orm contains 45 classes and traits. Here is an overview:
- CatchableException - Class used for a catchable database query exception
- Cell - Class to represent an existing cell within a row
- Cells - Class for a collection of many cells within a same row
- CellsIndex - Class for a collection of cells within different tables (keys are indexed)
- CellsMap - Root class for a collection of cells
- Classe - Class required to identify which class needs to be used by the different ORM components
- Col - Class to represent an existing column within a table
- ColRelation - Class to access the relation data of a column
- ColSchema - Class used to parse the information schema of a column
- Cols - Class for a collection of many columns within a same table
- ColsIndex - Class for a collection of cols within different tables (keys are indexed)
- ColsMap - Root class for a collection of cols
- Db - Class used to query the database and to link the results to the different ORM components
- Exception - Class used for a database query exception
- History - Class used to store the history of requests made to the database object
- Lang - Extended class for an object containing language texts related to the database
- Map - Root class for a collection of cells, cols or rows
- Operation - Abstract class used for a complex operation on the database
- Pdo - Class used to query the database using the PDO object
- PdoSql - Class used to build an sql query in a object-oriented way, not linked to ORM components
- Relation - Abstract class that is extended by ColRelation and Relation
- Row - Class to represent an existing row within a table
- RowOperation - Abstract class used for a complex operation on a table row
- Rows - Class for a collection of many rows within a same table
- RowsIndex - Class for a collection of rows within different tables (keys are indexed)
- RowsMap - Root class for a collection of rows
- Schema - Class that provides a schema for a database with tables and columns information
- Sql - Class used to build a sql query in a object-oriented way, uses the DB class (linked to the ORM components)
- Syntax - Abstract class with static methods to generate SQL syntax
- Mysql - Class with static methods to generate MySQL syntax strings (compatible with MySQL and MariaDB)
- Table - Class to represent an existing table within a database
- TableClasse - Class required to identify which class needs to be used by the different ORM components of a table
- TableOperation - Abstract class used for a complex operation on a database table
- TableRelation - Class to access the relation data of a table
- Tables - Class for a collection of many tables within a same database
- _colCell - Trait that provides common methods for Col and Cell objects
- _dbAccess - Trait that grants database access to the class using
- _mapIndex - Trait that grants common methods for indexed collections (cols, cells, rows)
- _tableAccess - Trait that grants table access to the class using
QuidPHP/Orm contains 26 test classes:
- CatchableException - Class for testing Quid\Orm\CatchableException
- Cell - Class for testing Quid\Orm\Cell
- Cells - Class for testing Quid\Orm\Cells
- CellsIndex - Class for testing Quid\Orm\CellsIndex
- Classe - Class for testing Quid\Orm\Classe
- Col - Class for testing Quid\Orm\Col
- ColRelation - Class for testing Quid\Orm\ColRelation
- ColSchema - Class for testing Quid\Orm\ColSchema
- Cols - Class for testing Quid\Orm\Cols
- ColsIndex - Class for testing Quid\Orm\ColsIndex
- Db - Class for testing Quid\Orm\Db
- Exception - Class for testing Quid\Orm\Exception
- History - Class for testing Quid\Orm\History
- Lang - Class for testing Quid\Orm\Lang
- Pdo - Class for testing Quid\Orm\Pdo
- PdoSql - Class for testing Quid\Orm\PdoSql
- Row - Class for testing Quid\Orm\Row
- Rows - Class for testing Quid\Orm\Rows
- RowsIndex - Class for testing Quid\Orm\RowsIndex
- Schema - Class for testing Quid\Orm\Schema
- Sql - Class for testing Quid\Orm\Sql
- Syntax - Class for testing Quid\Orm\Syntax
- Table - Class for testing Quid\Orm\Table
- TableClasse - Class for testing Quid\Orm\TableClasse
- TableRelation - Class for testing Quid\Orm\TableRelation
- Tables - Class for testing Quid\Orm\Tables
QuidPHP/Orm testsuite can be run by creating a new QuidPHP/Assert project.