Repository
in package
Tags
Table of Contents
Constants
- entityClass : string = ''
- The class this repository holds.
Properties
- $connection : IDBConnection
- $entityManager : EntityManager
- $entityClassOverride : string|null
Methods
- delete() : void
- deleteBy() : int
- findBy() : Generator<string|int, T>
- Finds entities by a set of criteria, keyed by property name.
- findOneBy() : T
- Finds a single entity by a set of criteria, keyed by property name.
- getTableName() : string
- insert() : T
- Inserts the entity and populates its generated primary key.
- insertOrUpdate() : T
- Tries to create a new entry in the db from an entity and updates an existing entry if duplicate keys are detected by the database
- update() : T
- yieldAll() : Generator<string|int, T>
- buildDebugMessage() : string
- buildJoinedSelectQuery() : EntityInfo}>}
- Builds a select query resolving OneToOne and ManyToOne relations via a LEFT JOIN.
- findJoinedEntity() : T
- getEntityClass() : class-string
- getJoinedSelectQueryBuilder() : EntityInfo}>}
- hydrateRow() : S
- Builds an entity from a flat row of its own scalar columns. OneToOne relations are always left null here; resolving them is mapJoinedRowToEntity()'s job.
- isGeneratedIdColumn() : bool
- joinRelation() : void
- mapJoinedRowToEntity() : T
- yieldJoinedEntities() : Generator<string|int, T>
Constants
entityClass
The class this repository holds.
public
string
entityClass
= ''
Tags
Properties
$connection read-only
protected
IDBConnection
$connection
$entityManager read-only
protected
EntityManager
$entityManager
$entityClassOverride read-only
private
string|null
$entityClassOverride
= null
Methods
delete()
public
delete(object $entity) : void
Parameters
- $entity : object
Tags
deleteBy()
public
deleteBy(array<string, int|float|string|null|DateTime|array<int, int|float|string>> $criteria[, int|null $limit = null ]) : int
Parameters
- $criteria : array<string, int|float|string|null|DateTime|array<int, int|float|string>>
- $limit : int|null = null
Tags
Return values
int —The number of rows deleted
findBy()
Finds entities by a set of criteria, keyed by property name.
public
findBy(array<string, int|float|string|null|DateTime|array<int, int|float|string>> $criteria[, array<string, SortDirection> $orderBy = [] ][, int|null $limit = null ][, int|null $offset = null ]) : Generator<string|int, T>
Parameters
- $criteria : array<string, int|float|string|null|DateTime|array<int, int|float|string>>
- $orderBy : array<string, SortDirection> = []
- $limit : int|null = null
- $offset : int|null = null
Tags
Return values
Generator<string|int, T>findOneBy()
Finds a single entity by a set of criteria, keyed by property name.
public
findOneBy(array<string, int|float|string|null|DateTime|array<int, int|float|string>> $criteria[, array<string, SortDirection> $orderBy = [] ]) : T
Parameters
- $criteria : array<string, int|float|string|null|DateTime|array<int, int|float|string>>
- $orderBy : array<string, SortDirection> = []
Tags
Return values
TgetTableName()
public
getTableName() : string
Tags
Return values
stringinsert()
Inserts the entity and populates its generated primary key.
public
insert(object $entity) : T
Parameters
- $entity : object
Tags
Return values
TinsertOrUpdate()
Tries to create a new entry in the db from an entity and updates an existing entry if duplicate keys are detected by the database
public
insertOrUpdate(T $entity) : T
Parameters
- $entity : T
-
the entity that should be created/updated
Tags
Return values
T —the saved entity with the (new) id
update()
public
update(object $entity) : T
Parameters
- $entity : object
Tags
Return values
TyieldAll()
public
yieldAll() : Generator<string|int, T>
Tags
Return values
Generator<string|int, T>buildDebugMessage()
private
buildDebugMessage(string $msg, IQueryBuilder $sql) : string
Parameters
- $msg : string
- $sql : IQueryBuilder
Return values
stringbuildJoinedSelectQuery()
Builds a select query resolving OneToOne and ManyToOne relations via a LEFT JOIN.
private
buildJoinedSelectQuery(EntityInfo $entityInfo) : EntityInfo}>}
Columns are aliased e_<column> (main entity) and r<index>_<column> (each relation)
to stay unique even when tables share column names.
Parameters
- $entityInfo : EntityInfo
Return values
EntityInfo}>}findJoinedEntity()
private
findJoinedEntity(IQueryBuilder $query, array<string, EntityInfo}> $relations) : T
Parameters
- $query : IQueryBuilder
- $relations : array<string, EntityInfo}>
Tags
Return values
TgetEntityClass()
private
getEntityClass() : class-string
Return values
class-stringgetJoinedSelectQueryBuilder()
private
getJoinedSelectQueryBuilder(array<string, int|float|string|null|DateTime|array<int, int|float|string>> $criteria[, array<string, SortDirection> $orderBy = [] ]) : EntityInfo}>}
Parameters
- $criteria : array<string, int|float|string|null|DateTime|array<int, int|float|string>>
- $orderBy : array<string, SortDirection> = []
Return values
EntityInfo}>}hydrateRow()
Builds an entity from a flat row of its own scalar columns. OneToOne relations are always left null here; resolving them is mapJoinedRowToEntity()'s job.
private
hydrateRow(S> $entityClass, array<string, mixed> $row) : S
Parameters
- $entityClass : S>
- $row : array<string, mixed>
Tags
Return values
SisGeneratedIdColumn()
private
isGeneratedIdColumn(EntityInfo $entityInfo, string $column) : bool
Parameters
- $entityInfo : EntityInfo
- $column : string
Return values
booljoinRelation()
private
joinRelation(IQueryBuilder $qb, string $alias, EntityInfo $targetEntityInfo, string $leftExpr, string $rightExpr) : void
Parameters
- $qb : IQueryBuilder
- $alias : string
- $targetEntityInfo : EntityInfo
- $leftExpr : string
- $rightExpr : string
mapJoinedRowToEntity()
private
mapJoinedRowToEntity(array<string, EntityInfo}> $relations, array<string, mixed> $row) : T
Parameters
- $relations : array<string, EntityInfo}>
- $row : array<string, mixed>
Return values
TyieldJoinedEntities()
private
yieldJoinedEntities(IQueryBuilder $query, array<string, EntityInfo}> $relations) : Generator<string|int, T>
Parameters
- $query : IQueryBuilder
- $relations : array<string, EntityInfo}>