rotexsoft / gdao
A package containing class and interface definitions that can be used as a basis for a Table Data Gateway (http://bit.ly/1F8Zjfc) and Data Mapper (http://bit.ly/1hD2qCc) implementation of a database access library that performs data manipulation (DM) tasks.
Installs: 2 792
Dependents: 1
Suggesters: 0
Security: 0
Stars: 1
Watchers: 3
Forks: 0
Open Issues: 5
Requires
- php: >=8.1
Requires (Dev)
- php-coveralls/php-coveralls: ^2.0
- phpunit/phpunit: ^10.0
- rector/rector: ^1.0.0
- vimeo/psalm: ^5.4.0
Suggests
- rotexsoft/leanorm: A Concrete Implementation of the Abstract Classes and Interfaces in rotexsoft/gdao. A light weight data-access / ORM library.
README
Description
A package containing class and interface definitions that can be used as a basis for a Table Data Gateway (http://bit.ly/1F8Zjfc) and Data Mapper (http://bit.ly/1hD2qCc) implementation of a database access library that performs data manipulation (DM) tasks. Below are its main components:
-
an abstract Model class (it's the Table Data Gateway and Data Mapper that interacts with a database table by performing DM tasks like Selection, Insertion, Deletion & Updating of data)
-
a RecordInterface interface (contains definitions of methods that any class representing a row of data in a database table, MUST IMPLEMENT. Such classes can only access a database table via an instance of the Model class)
-
an optional CollectionInterface interface (contains definitions of methods that any class that is to serve as a collection of multiple instances of RecordInterface objects, MUST IMPLEMENT)
This API is intended to make it easy / trivial to swap out different implementations of each of the Main classes. For example, an application may have been written to use a package that implements this API in the following classes: ModelYY, CollectionYY (which implements CollectionInterface) and RecordYY (which implements RecordInterface). In the future if another package implementing this API has a ModelZZ which performs some operations more efficiently than ModelYY, you should be able to easily substitute ModelYY with ModelZZ if all your data access code strictly adheres to the GDAO API (you would now end up using ModelZZ, CollectionYY and RecordYY in your updated code; which should all work nicely together).
This package isn't meant to perform database schema management tasks like creating/altering tables, etc. However, it exposes a PDO object (via \GDAO\Model->getPDO()) that can be used to perform such tasks and other data manipulation (DM) tasks that cannot be accomplished via this API.
Assumptions and Conventions in this API.
-
Each database table has a single auto-incrementing numeric primary key column (composite primary keys are not supported; however a single primary key column that is non-numeric should work)
-
Implementation(s) of this API must be powered by at least one PDO object. Vendor specific php database extensions (eg. mysqli, SQLite3 etc.) are not to be used in implementation(s) of this API.
-
This API is architected with the intent of having Records and Collections created via the Model.
Users of any implementation of this API should not be directly instantiating new Collections or Records via their constructors, instead they should create them by calling the appropriate implementation of \GDAO\Model::createCollection(..) or \GDAO\Model::createRecord(..).
Definition of terms used in the phpdoc comment blocks:
-
Consumer: an individual developer or group of developers that use a package / library containing concrete implementation of the APIs specified in the abstract classes in this package.
-
Implementer: The developer that creates a package / library containing concrete implementation of the APIs specified in the abstract classes in this package.
Running Tests
./vendor/bin/phpunit --coverage-text
Branching
These are the branches in this repository:
- master: contains code for the latest major version of this package
- 2.x: contains code for the 2.x version of this package
- 1.X: contains code for the 1.x version of this package. This version never got a stable release and has been abandoned