PDORepository
MMO\pdo · 1 symbol · generated 5 Oct 2026
PDORepository
PDORepository.php:37A aRepository backed by a SQL database: one Table per collection.
- Namespace
MMO\pdo- Extends
- aRepository
Index
| handler | ||
| lastIds | ||
| pendingId | A placeholder id, handed to a new entity whose real id the DATABASE will generate. | |
| tables | ||
| addTable($table, $name) | Register a table and the collection that holds its rows. | |
| commitEntity($entity, $commit, $counts) | Persist one entity. Called from inside onCommit's transaction. | |
| createEntity($class, $data, $collection) | ||
| debugName() | ||
| dropCollection($collection) | Drop a collection's table, and forget the collection. | |
| executeQuery($query, $opts) | Run a query against the database. | |
| exportRow($table, $values) | ||
| exportValue($table, $column, $value) | Convert one entity value into something a column can hold (PDOExporter), using the column's own type to decide a date's format. | |
| generateId($collection) | An id is not given twice by one repository: what is keyed by an id (a scope edms.files.12, a link, a cache) would apply to the next entity. | |
| getHandler() | ||
| getTable($collection) | ||
| install() | Create any of this repository's tables that the database does not have yet. | |
| IsPendingId($id) static | ||
| loadEntities($collection, $rows, $reload) | Turn rows into entities, reusing the instance a row's id already has in the collection so the same record is never represented twice. | |
| logsQueries() | ||
| nextPendingId() | ||
| onCommit($commit) | Persist every entity of this commit that belongs to one of this repository's collections. | |
| queryColumns($query, $table) | The columns a query should actually SELECT. | |
| rowId($class, $row) | ||
| setHandler($handler) | ||
| setTables($tables) | Declare this repository's tables from configuration, so an application describes its schema in one place instead of building every Table by hand. | |
| uid() | ||
| unknownColumns($filter, $table, $unknown) | Collect the filter's column references that this table does not have. | |
| unregister() | Detach this repository, and its collections, from the global Commit / Fetch events. | |
| __construct($handler, $collections) |
Properties4
handler
- Type
- iHandler
lastIds
- Type
- array
pendingId
A placeholder id, handed to a new entity whose real id the DATABASE will generate.
- Type
- int
tables
- Type
- array
- See
setTables-- declared here so the configuration keytablesreaches it.
Methods25
addTable($table, $name)
PDORepository.php:149Register a table and the collection that holds its rows.
| $table | Table | |
| $name = null | null | string | the collection's name; the table's own name by default |
| returns | iCollection |
commitEntity($entity, $commit, $counts)
PDORepository.php:485Persist one entity. Called from inside onCommit's transaction.
createEntity($class, $data, $collection)
PDORepository.php:213- See
aRepository::createEntity, making sure the new entity has an id of some kind.
| $class | string | |
| $data = [] | array | |
| $collection = null | null | iCollection | |
| returns | iEntity |
debugName()
PDORepository.php:91| returns | string |
dropCollection($collection)
PDORepository.php:169Drop a collection's table, and forget the collection.
| $collection | iCollection | string | |
| returns | bool |
executeQuery($query, $opts)
PDORepository.php:328Run a query against the database.
exportRow($table, $values)
PDORepository.php:424exportValue($table, $column, $value)
PDORepository.php:414Convert one entity value into something a column can hold (PDOExporter), using the column's own type to decide a date's format.
generateId($collection)
PDORepository.php:248An id is not given twice by one repository: what is keyed by an id (a scope edms.files.12, a link, a cache) would apply to the next entity.
| $collection | iCollection | |
| returns | int | one more than the highest id in use -- counting both the rows already stored AND the entities already created in this collection, since several can be created before any of them is committed -- and than the ids of the entities removed ($lastIds). |
getHandler()
PDORepository.php:79| returns | iHandler |
getTable($collection)
PDORepository.php:161| $collection | iCollection | string | |
| returns | Table | the table behind a collection |
| throws | if there is none |
install()
PDORepository.php:131Create any of this repository's tables that the database does not have yet.
| returns | array | the names of the tables that were created |
IsPendingId($id)
staticPDORepository.php:200loadEntities($collection, $rows, $reload)
PDORepository.php:369Turn rows into entities, reusing the instance a row's id already has in the collection so the same record is never represented twice.
| $collection | iCollection | |
| $rows | iterable | |
| $reload = false | bool | if true, refresh an already-loaded entity from its row |
| returns | array |
logsQueries()
PDORepository.php:59nextPendingId()
PDORepository.php:195| returns | int | the next placeholder id (-1, -2, …). $pendingId |
onCommit($commit)
PDORepository.php:441Persist every entity of this commit that belongs to one of this repository's collections.
queryColumns($query, $table)
PDORepository.php:280The columns a query should actually SELECT.
rowId($class, $row)
PDORepository.php:395| $class | string | the collection's entity class |
| $row | array | |
| returns | string | the row's id in the form PDOEntity::getId produces, or '' if the row does not carry it |
setHandler($handler)
PDORepository.php:83setTables($tables)
PDORepository.php:110Declare this repository's tables from configuration, so an application describes its schema in one place instead of building every Table by hand.
| $tables | array | name => [column => sql definition, …], or name => Table for one already built |
| returns | void |
uid()
PDORepository.php:87| returns | string |
unknownColumns($filter, $table, $unknown)
PDORepository.php:306Collect the filter's column references that this table does not have.
unregister()
PDORepository.php:73Detach this repository, and its collections, from the global Commit / Fetch events.
| returns | void |
__construct($handler, $collections)
PDORepository.php:49| $handler | iHandler | |
| $collections = [] | array | see aRepository::setCollections -- their tables must already be known to $handler. addTable is usually easier. |
Inherited members (26)
| Properties | Declared by | Description | |
|---|---|---|---|
collections | aRepository |
| Methods | Declared by | Description | |
|---|---|---|---|
addCollection($name, $collection) | aRepository | Add collection | |
createCollection($name, $entityClass, $collectionId) | aRepository | Create and register a plain Collection for entities of $entityClass. | |
createLog($type, $origin, $collection, $data, $filters, $sorts, $limit, $offset) | aRepository | Build (but not dispatch) a LogQuery entity describing a data-mutating operation, stored in the repository's LogQuery collection (if one is registered). | |
forceCommit($origin, $entities) | aRepository | ||
getCollection($name) | aRepository | ||
getCollectionByClass($entityClass, $allowChildClass) | aRepository | Find the collection whose entities are (an exact match, or optionally a subclass of) $entityClass. | |
getCollectionName($collection) | aRepository | ||
getCollections() | aRepository | ||
getDistinct($collection, $key) | aRepository | Every value one property takes across a collection, once each, in ascending order. | |
getEntities() | aRepository | ||
getIterator() | aRepository | \IteratorAggregate::getIterator -- iterates name => iCollection | |
hasCollection($collection) | aRepository | ||
hideLogData($collection, $data) | aRepository | What a repository logs is what it wrote (mmo.pdo's row, mmo.mongodb's document or its changes), hidden properties (ArrayProperty::isHidden) included, and a log is exported… | |
logDelete($origin, $collection, $data, $filters, $sorts, $limit, $offset) | aRepository | Log and dispatch a DELETE operation. | |
logInsert($origin, $collection, $data, $filters, $sorts, $limit, $offset) | aRepository | Log and dispatch an INSERT operation. | |
logStatus($origin, $collection, $data, $filters, $sorts, $limit, $offset) | aRepository | Log and dispatch a STATUS-change operation. | |
logUpdate($origin, $collection, $data, $filters, $sorts, $limit, $offset) | aRepository | Log and dispatch an UPDATE operation. | |
offsetExists($key) | aRepository | \ArrayAccess::offsetExists | |
offsetGet($key) | aRepository | \ArrayAccess::offsetGet | |
offsetSet($key, $value) | aRepository | \ArrayAccess::offsetSet -- equivalent to addCollection | |
offsetUnset($key) | aRepository | \ArrayAccess::offsetUnset | |
onFetch($event) | aRepository | Listener for Fetch: resolves a repository-uid/collection-id#id (or repository-uid/collection-id#id/nested/path for an embedded value) URL, what Ent… | |
searchText($query, $text) | aRepository | Full-text search. Not implemented at this level -- a concrete repository backed by a search-capable store should override this. | |
setCollections($cols) | aRepository | Register a batch of collections at once, e.g. | |
__wakeup() | aRepository | Register this repository's onCommit / onFetch as listeners on the global |