interface EntityPersister (View source)

Entity persister interface Define the behavior that should be implemented by all entity persisters.

Methods

getClassMetadata()

No description

getResultSetMapping()

Gets the ResultSetMapping used for hydration.

array
getInserts()

Get all queued inserts.

string
getInsertSQL()

No description

string
getSelectSQL(array|Criteria $criteria, array|null $assoc = null, int|null $lockMode = null, int|null $limit = null, int|null $offset = null, array $orderBy = null)

Gets the SELECT SQL to select one or more entities by a set of field criteria.

string
getCountSQL(array|Criteria $criteria = [])

Get the COUNT SQL to count entities (optionally based on a criteria)

array
expandParameters($criteria)

Expands the parameters from the given criteria and use the correct binding types if found.

array
expandCriteriaParameters(Criteria $criteria)

Expands Criteria Parameters by walking the expressions and grabbing all parameters and types from it.

string
getSelectConditionStatementSQL(string $field, mixed $value, array|null $assoc = null, string|null $comparison = null)

Gets the SQL WHERE condition for matching a field with a given value.

void
addInsert(object $entity)

Adds an entity to the queued insertions.

array
executeInserts()

Executes all queued entity insertions and returns any generated post-insert identifiers that were created as a result of the insertions.

void
update(object $entity)

Updates a managed entity. The entity is updated according to its current changeset in the running UnitOfWork. If there is no changeset, nothing is updated.

bool
delete(object $entity)

Deletes a managed entity.

int
count(array|Criteria $criteria = [])

Count entities (optionally filtered by a criteria)

string
getOwningTable(string $fieldName)

Gets the name of the table that owns the column the given field is mapped to.

object|null
load(array $criteria, object|null $entity = null, array|null $assoc = null, array $hints = [], int|null $lockMode = null, int|null $limit = null, array $orderBy = null)

Loads an entity by a list of field criteria.

object
loadById(array $identifier, object|null $entity = null)

Loads an entity by identifier.

object
loadOneToOneEntity(array $assoc, object $sourceEntity, array $identifier = [])

Loads an entity of this persister's mapped class as part of a single-valued association from another entity.

void
refresh(array $id, object $entity, int|null $lockMode = null)

Refreshes a managed entity.

array
loadCriteria(Criteria $criteria)

Loads Entities matching the given Criteria object.

array
loadAll(array $criteria = [], array $orderBy = null, int|null $limit = null, int|null $offset = null)

Loads a list of entities by a list of field criteria.

array
getManyToManyCollection(array $assoc, object $sourceEntity, int|null $offset = null, int|null $limit = null)

Gets (sliced or full) elements of the given collection.

array
loadManyToManyCollection(array $assoc, object $sourceEntity, PersistentCollection $collection)

Loads a collection of entities of a many-to-many association.

array
loadOneToManyCollection(array $assoc, object $sourceEntity, PersistentCollection $collection)

Loads a collection of entities in a one-to-many association.

void
lock(array $criteria, int $lockMode)

Locks all rows of this entity matching the given criteria with the specified pessimistic lock mode.

array
getOneToManyCollection(array $assoc, object $sourceEntity, int|null $offset = null, int|null $limit = null)

Returns an array with (sliced or full list) of elements in the specified collection.

boolean
exists(object $entity, Criteria $extraConditions = null)

Checks whether the given managed entity exists in the database.

Details

ClassMetadata getClassMetadata()

Return Value

ClassMetadata

ResultSetMapping getResultSetMapping()

Gets the ResultSetMapping used for hydration.

Return Value

ResultSetMapping

array getInserts()

Get all queued inserts.

Return Value

array

string getInsertSQL()

Return Value

string

string getSelectSQL(array|Criteria $criteria, array|null $assoc = null, int|null $lockMode = null, int|null $limit = null, int|null $offset = null, array $orderBy = null)

Gets the SELECT SQL to select one or more entities by a set of field criteria.

Parameters

array|Criteria $criteria
array|null $assoc
int|null $lockMode
int|null $limit
int|null $offset
array $orderBy

Return Value

string

string getCountSQL(array|Criteria $criteria = [])

Get the COUNT SQL to count entities (optionally based on a criteria)

Parameters

array|Criteria $criteria

Return Value

string

array expandParameters($criteria)

Expands the parameters from the given criteria and use the correct binding types if found.

Parameters

$criteria

Return Value

array

array expandCriteriaParameters(Criteria $criteria)

Expands Criteria Parameters by walking the expressions and grabbing all parameters and types from it.

Parameters

Criteria $criteria

Return Value

array

string getSelectConditionStatementSQL(string $field, mixed $value, array|null $assoc = null, string|null $comparison = null)

Gets the SQL WHERE condition for matching a field with a given value.

Parameters

string $field
mixed $value
array|null $assoc
string|null $comparison

Return Value

string

void addInsert(object $entity)

Adds an entity to the queued insertions.

The entity remains queued until {@link executeInserts} is invoked.

Parameters

object $entity The entity to queue for insertion.

Return Value

void

array executeInserts()

Executes all queued entity insertions and returns any generated post-insert identifiers that were created as a result of the insertions.

If no inserts are queued, invoking this method is a NOOP.

Return Value

array An array of any generated post-insert IDs. This will be an empty array if the entity class does not use the IDENTITY generation strategy.

void update(object $entity)

Updates a managed entity. The entity is updated according to its current changeset in the running UnitOfWork. If there is no changeset, nothing is updated.

Parameters

object $entity The entity to update.

Return Value

void

bool delete(object $entity)

Deletes a managed entity.

The entity to delete must be managed and have a persistent identifier. The deletion happens instantaneously.

Subclasses may override this method to customize the semantics of entity deletion.

Parameters

object $entity The entity to delete.

Return Value

bool TRUE if the entity got deleted in the database, FALSE otherwise.

int count(array|Criteria $criteria = [])

Count entities (optionally filtered by a criteria)

Parameters

array|Criteria $criteria

Return Value

int

string getOwningTable(string $fieldName)

Gets the name of the table that owns the column the given field is mapped to.

The default implementation in BasicEntityPersister always returns the name of the table the entity type of this persister is mapped to, since an entity is always persisted to a single table with a BasicEntityPersister.

Parameters

string $fieldName The field name.

Return Value

string The table name.

object|null load(array $criteria, object|null $entity = null, array|null $assoc = null, array $hints = [], int|null $lockMode = null, int|null $limit = null, array $orderBy = null)

Loads an entity by a list of field criteria.

Parameters

array $criteria The criteria by which to load the entity.
object|null $entity The entity to load the data into. If not specified, a new entity is created.
array|null $assoc The association that connects the entity to load to another entity, if any.
array $hints Hints for entity creation.
int|null $lockMode One of the \Doctrine\DBAL\LockMode::* constants or NULL if no specific lock mode should be used for loading the entity.
int|null $limit Limit number of results.
array $orderBy Criteria to order by.

Return Value

object|null The loaded and managed entity instance or NULL if the entity can not be found.

object loadById(array $identifier, object|null $entity = null)

Loads an entity by identifier.

Parameters

array $identifier The entity identifier.
object|null $entity The entity to load the data into. If not specified, a new entity is created.

Return Value

object The loaded and managed entity instance or NULL if the entity can not be found.

object loadOneToOneEntity(array $assoc, object $sourceEntity, array $identifier = [])

Loads an entity of this persister's mapped class as part of a single-valued association from another entity.

Parameters

array $assoc The association to load.
object $sourceEntity The entity that owns the association (not necessarily the "owning side").
array $identifier The identifier of the entity to load. Must be provided if the association to load represents the owning side, otherwise the identifier is derived from the $sourceEntity.

Return Value

object The loaded and managed entity instance or NULL if the entity can not be found.

Exceptions

MappingException

void refresh(array $id, object $entity, int|null $lockMode = null)

Refreshes a managed entity.

Parameters

array $id The identifier of the entity as an associative array from column or field names to values.
object $entity The entity to refresh.
int|null $lockMode One of the \Doctrine\DBAL\LockMode::* constants or NULL if no specific lock mode should be used for refreshing the managed entity.

Return Value

void

array loadCriteria(Criteria $criteria)

Loads Entities matching the given Criteria object.

Parameters

Criteria $criteria

Return Value

array

array loadAll(array $criteria = [], array $orderBy = null, int|null $limit = null, int|null $offset = null)

Loads a list of entities by a list of field criteria.

Parameters

array $criteria
array $orderBy
int|null $limit
int|null $offset

Return Value

array

array getManyToManyCollection(array $assoc, object $sourceEntity, int|null $offset = null, int|null $limit = null)

Gets (sliced or full) elements of the given collection.

Parameters

array $assoc
object $sourceEntity
int|null $offset
int|null $limit

Return Value

array

array loadManyToManyCollection(array $assoc, object $sourceEntity, PersistentCollection $collection)

Loads a collection of entities of a many-to-many association.

Parameters

array $assoc The association mapping of the association being loaded.
object $sourceEntity The entity that owns the collection.
PersistentCollection $collection The collection to fill.

Return Value

array

array loadOneToManyCollection(array $assoc, object $sourceEntity, PersistentCollection $collection)

Loads a collection of entities in a one-to-many association.

Parameters

array $assoc
object $sourceEntity
PersistentCollection $collection The collection to load/fill.

Return Value

array

void lock(array $criteria, int $lockMode)

Locks all rows of this entity matching the given criteria with the specified pessimistic lock mode.

Parameters

array $criteria
int $lockMode One of the Doctrine\DBAL\LockMode::* constants.

Return Value

void

array getOneToManyCollection(array $assoc, object $sourceEntity, int|null $offset = null, int|null $limit = null)

Returns an array with (sliced or full list) of elements in the specified collection.

Parameters

array $assoc
object $sourceEntity
int|null $offset
int|null $limit

Return Value

array

boolean exists(object $entity, Criteria $extraConditions = null)

Checks whether the given managed entity exists in the database.

Parameters

object $entity
Criteria $extraConditions

Return Value

boolean TRUE if the entity exists in the database, FALSE otherwise.