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.

3.0.1 2024-02-05 09:16 UTC

README

Run PHP Tests and Code Quality Tools   GitHub release (latest SemVer)   GitHub   Coverage Status   GitHub repo size   Packagist Downloads   GitHub top language   Packagist PHP Version Support   GitHub commits since latest release (by date)   GitHub last commit   GitHub Release Date   Libraries.io dependency status for GitHub repo

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.

GDAO Classes & Interfaces

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

Dev Notes

  • Old versions have branches corresponding to their version numbers (e.g. 1.X) while the most current / actively being developed version is on the master branch.