Doctrine\ORM\Persisters\BasicEntityPersister
A BasicEntityPersiter maps an entity to a single table in a relational database.
A persister is always responsible for a single entity type.
EntityPersisters are used during a UnitOfWork to apply any changes to the persistent
state of entities onto a relational database when the UnitOfWork is committed,
as well as for basic querying of entities and their associations (not DQL).
The persisting operations that are invoked during a commit of a UnitOfWork to
persist the persistent entity state are:
- : To schedule an entity for insertion.
- : To execute all scheduled insertions.
- : To update the persistent state of an entity.
- : To delete the persistent state of an entity.
As can be seen from the above list, insertions are batched and executed all at once
for increased efficiency.
The querying operations invoked during a UnitOfWork, either through direct find
requests or lazy-loading, are the following:
- : Loads (the state of) a single, managed entity.
- : Loads multiple, managed entities.
- : Loads a one/many-to-one entity association (lazy-loading).
- : Loads a one-to-many entity association (lazy-loading).
- : Loads a many-to-many entity association (lazy-loading).
The BasicEntityPersister implementation provides the default behavior for
persisting and querying entities that are mapped to a single database table.
Subclasses can be created to provide custom persisting and querying strategies,
i.e. spanning multiple tables.
- Author: Roman Borschel <roman@code-factory.org>
Synopsis
- // members
- private array $comparisonMap;
- protected ClassMetadata $_class;
- protected Connection $_conn;
- protected AbstractPlatform $_platform;
- protected EntityManager $_em;
- protected array $_queuedInserts;
- protected ResultSetMapping $_rsm;
- protected array $_columnTypes;
- protected array $quotedColumns;
- private string $_insertSql;
- protected string $_selectColumnListSql;
- protected string $_selectJoinSql;
- protected integer $_sqlAliasCounter;
- protected array $_sqlTableAliases;
- protected QuoteStrategy $quoteStrategy;
- // methods
- public void __construct()
- public ClassMetadata getClassMetadata()
- public void addInsert()
- public array executeInserts()
- protected void assignDefaultVersionValue()
- protected mixed fetchVersionValue()
- public void update()
- protected final void _updateTable()
- protected void deleteJoinTableRecords()
- public void delete()
- protected array _prepareUpdateData()
- protected array _prepareInsertData()
- public string getOwningTable()
- public load()
- public loadOneToOneEntity()
- public void refresh()
- public array loadCriteria()
- private array(array() expandCriteriaParameters()
- public array loadAll()
- public array getManyToManyCollection()
- private array loadArrayFromStatement()
- private array loadCollectionFromStatement()
- public array loadManyToManyCollection()
- private void getManyToManyStatement()
- protected string _getSelectEntitiesSQL()
- protected final string _getOrderBySQL()
- protected string _getSelectColumnListSQL()
- protected string _getSelectColumnAssociationSQL()
- protected string _getSelectManyToManyJoinSQL()
- protected string _getInsertSQL()
- protected array _getInsertColumnList()
- protected void _getSelectColumnSQL()
- protected string _getSQLTableAlias()
- public void lock()
- protected string getLockTablesSql()
- protected string _getSelectConditionCriteriaSQL()
- public string getSelectConditionStatementSQL()
- protected string getSelectConditionStatementColumnSQL()
- protected string _getSelectConditionSQL()
- public array getOneToManyCollection()
- public void loadOneToManyCollection()
- private Statement getOneToManyStatement()
- private array expandParameters()
- private integer getType()
- private mixed getValue()
- private mixed getIndividualValue()
- public boolean exists()
- protected string getJoinSQLForJoinColumns()
- public string getSQLColumnAlias()
- protected string generateFilterConditionSQL()
Hierarchy
Extended by
Tasks
Line | Task |
---|---|
459+ | Add check for platform if it supports foreign keys/cascading. |
463 | this only covers scenarios with no inheritance or of the same level. Is there something |
666+ | Check identity map? loadById method? Try to guess whether $criteria is the id? |
1013+ | Refactor: _getSelectSQL(...) |
1096+ | Rename: _getSelectColumnsSQL() |
1367+ | Reconsider. Binding table aliases to class names is not such a good idea. |
Members
private
- $_insertSql
—
string
The INSERT SQL statement used for entities handled by this persister. - $comparisonMap — array
protected
- $_class
—
\Doctrine\ORM\Mapping\ClassMetadata
Metadata object that describes the mapping of the mapped entity class. - $_columnTypes
—
array
The map of column names to DBAL mapping types of all prepared columns used when INSERTing or UPDATEing an entity. - $_conn
—
\Doctrine\DBAL\Connection
The underlying DBAL Connection of the used EntityManager. - $_em
—
\Doctrine\ORM\EntityManager
The EntityManager instance. - $_platform
—
\Doctrine\DBAL\Platforms\AbstractPlatform
The database platform. - $_queuedInserts
—
array
Queued inserts. - $_rsm
—
Doctrine\ORM\Persisters\Query\ResultSetMapping
ResultSetMapping that is used for all queries. Is generated lazily once per request. - $_selectColumnListSql
—
string
The SELECT column list SQL fragment used for querying entities by this persister. - $_selectJoinSql
—
string
The JOIN SQL fragement used to eagerly load all many-to-one and one-to-one associations configured as FETCH_EAGER, aswell as all inverse one-to-one associations. - $_sqlAliasCounter
—
integer
Counter for creating unique SQL table and column aliases. - $_sqlTableAliases
—
array
Map from class names (FQCN) to the corresponding generated SQL table aliases. - $quoteStrategy
—
\Doctrine\ORM\Mapping\QuoteStrategy
The quote strategy. - $quotedColumns
—
array
The map of quoted column names.
Methods
private
- expandCriteriaParameters() — Expand Criteria Parameters by walking the expressions and grabbing all parameters and types from it.
- expandParameters() — Expand the parameters from the given criteria and use the correct binding types if found.
- getIndividualValue() — Retrieve an invidiual parameter value
- getManyToManyStatement()
- getOneToManyStatement() — Build criteria and execute SQL statement to fetch the one to many entities from.
- getType() — Infer field type to be used by parameter type casting.
- getValue() — Retrieve parameter value
- loadArrayFromStatement() — Load an array of entities from a given dbal statement.
- loadCollectionFromStatement() — Hydrate a collection from a given dbal statement.
protected
- _getInsertColumnList() — Gets the list of columns to put in the INSERT SQL statement.
- _getInsertSQL() — Gets the INSERT SQL used by the persister to persist a new entity.
- _getOrderBySQL() — Gets the ORDER BY SQL snippet for ordered collections.
- _getSQLTableAlias() — Gets the SQL table alias for the given class name.
- _getSelectColumnAssociationSQL() — Gets the SQL join fragment used when selecting entities from an association.
- _getSelectColumnListSQL() — Gets the SQL fragment with the list of columns to select when querying for an entity in this persister.
- _getSelectColumnSQL() — Gets the SQL snippet of a qualified column name for the given field name.
- _getSelectConditionCriteriaSQL() — Get the Select Where Condition from a Criteria object.
- _getSelectConditionSQL() — Gets the conditional SQL fragment used in the WHERE clause when selecting entities in this persister.
- _getSelectEntitiesSQL() — Gets the SELECT SQL to select one or more entities by a set of field criteria.
- _getSelectManyToManyJoinSQL() — Gets the SQL join fragment used when selecting entities from a many-to-many association.
- _prepareInsertData() — Prepares the data changeset of a managed entity for database insertion (initial INSERT).
- _prepareUpdateData() — Prepares the changeset of an entity for database insertion (UPDATE).
- _updateTable() — Performs an UPDATE statement for an entity on a specific table.
- assignDefaultVersionValue() — Retrieves the default version value which was created by the preceding INSERT statement and assigns it back in to the entities version field.
- deleteJoinTableRecords()
- fetchVersionValue() — Fetch the current version value of a versioned entity.
- generateFilterConditionSQL() — Generates the filter SQL for a given entity and table alias.
- getJoinSQLForJoinColumns() — Generates the appropriate join SQL for the given join column.
- getLockTablesSql() — Get the FROM and optionally JOIN conditions to lock the entity managed by this persister.
- getSelectConditionStatementColumnSQL() — Build the left-hand-side of a where condition statement.
public
- __construct() — Initializes a new <tt>BasicEntityPersister</tt> that uses the given EntityManager and persists instances of the class described by the given ClassMetadata descriptor.
- addInsert() — Adds an entity to the queued insertions.
- delete() — Deletes a managed entity.
- executeInserts() — Executes all queued entity insertions and returns any generated post-insert identifiers that were created as a result of the insertions.
- exists() — Checks whether the given managed entity exists in the database.
- getClassMetadata()
- getManyToManyCollection() — Get (sliced or full) elements of the given collection.
- getOneToManyCollection() — Return an array with (sliced or full list) of elements in the specified collection.
- getOwningTable() — Gets the name of the table that owns the column the given field is mapped to.
- getSQLColumnAlias() — Gets an SQL column alias for a column name.
- getSelectConditionStatementSQL() — Get the SQL WHERE condition for matching a field with a given value.
- load() — Loads an entity by a list of field criteria.
- loadAll() — Loads a list of entities by a list of field criteria.
- loadCriteria() — Load Entities matching the given Criteria object
- loadManyToManyCollection() — Loads a collection of entities of a many-to-many association.
- loadOneToManyCollection() — Loads a collection of entities in a one-to-many association.
- loadOneToOneEntity() — Loads an entity of this persister's mapped class as part of a single-valued association from another entity.
- lock() — Lock all rows of this entity matching the given criteria with the specified pessimistic lock mode
- refresh() — Refreshes a managed entity.
- update() — 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.