EntityManager
public class EntityManager
www.doctrine-project.org
Constructor Summary | |
---|---|
EntityManager(Doctrine\DBAL\Connection conn, Doctrine\ORM\Configuration config, Doctrine\Common\EventManager eventManager) Creates a new EntityManager that operates on the given database connection and uses the given Configuration and EventManager implementations. |
Method Summary | |
---|---|
void | Starts a transaction on the underlying database connection. |
void | clear(string entityName) Clears the EntityManager. |
void | close() Closes the EntityManager. |
void | commit() Commits a transaction on the underlying database connection. |
boolean | contains(object entity) Determines whether an entity instance is managed in this EntityManager. |
object | copy(object entity, mixed deep) Creates a copy of the given entity. |
static EntityManager | create(mixed conn, Configuration config, EventManager eventManager) Factory method to create EntityManager instances. |
Doctrine\ORM\NativeQuery | createNamedNativeQuery(string name) Creates a NativeQuery from a named native query. |
Doctrine\ORM\Query | createNamedQuery(string name) Creates a Query from a named query. |
NativeQuery | createNativeQuery(string sql, ResultSetMapping rsm) Creates a native SQL query. |
Doctrine\ORM\Query | createQuery(mixed dql, string The) Creates a new Query object. |
QueryBuilder | Create a QueryBuilder instance |
void | detach(object entity) Detaches an entity from the EntityManager, causing a managed entity to become detached. |
object | find(string entityName, mixed identifier) Finds an Entity by its identifier. |
void | flush() Flushes all changes to objects that have been queued up to now to the database. |
Doctrine\ORM\Mapping\ClassMetadata | getClassMetadata(mixed className) Returns the metadata for a class. |
Doctrine\ORM\Configuration | Gets the Configuration used by the EntityManager. |
Doctrine\DBAL\Connection | Gets the database connection object used by the EntityManager. |
Doctrine\Common\EventManager | Gets the EventManager used by the EntityManager. |
ExpressionBuilder | Gets an ExpressionBuilder used for object-oriented construction of query expressions. |
Doctrine\ORM\Internal\Hydration\AbstractHydrator | getHydrator(int hydrationMode) Gets a hydrator for the given hydration mode. |
Doctrine\ORM\Mapping\ClassMetadataFactory | Gets the metadata factory used to gather the metadata of classes. |
ProxyFactory | Gets the proxy factory used by the EntityManager to create entity proxies. |
object | getReference(mixed entityName, mixed identifier) Gets a reference to the entity identified by the given type and identifier without actually loading it. |
EntityRepository | getRepository(string entityName) Gets the repository for an entity class. |
Doctrine\ORM\UnitOfWork | Gets the UnitOfWork used by the EntityManager to coordinate operations. |
object | merge(object entity) Merges the state of a detached entity into the persistence context of this EntityManager and returns the managed copy of the entity. |
Doctrine\ORM\Internal\Hydration\AbstractHydrator | newHydrator(int hydrationMode) Create a new instance for the given hydration mode. |
void | persist(mixed entity, object object) Tells the EntityManager to make an instance managed and persistent. |
void | refresh(object entity) Refreshes the persistent state of an entity from the database, overriding any local changes that have not yet been persisted. |
void | remove(object entity) Removes an entity instance. |
void | rollback() Performs a rollback on the underlying database connection and closes the EntityManager as it may now be in a corrupted state. |
public EntityManager(Doctrine\DBAL\Connection conn, Doctrine\ORM\Configuration config, Doctrine\Common\EventManager eventManager)
Creates a new EntityManager that operates on the given database connection and uses the given Configuration and EventManager implementations.
public void beginTransaction()
Starts a transaction on the underlying database connection.
public void clear(string entityName)
Clears the EntityManager. All entities that are currently managed by this EntityManager become detached.
public void close()
Closes the EntityManager. All entities that are currently managed by this EntityManager become detached. The EntityManager may no longer be used after it is closed.
public void commit()
Commits a transaction on the underlying database connection.
public boolean contains(object entity)
Determines whether an entity instance is managed in this EntityManager.
public object copy(object entity, mixed deep)
Creates a copy of the given entity. Can create a shallow or a deep copy.
public static EntityManager create(mixed conn, Configuration config, EventManager eventManager)
Factory method to create EntityManager instances.
public Doctrine\ORM\NativeQuery createNamedNativeQuery(string name)
Creates a NativeQuery from a named native query.
public Doctrine\ORM\Query createNamedQuery(string name)
Creates a Query from a named query.
public NativeQuery createNativeQuery(string sql, ResultSetMapping rsm)
Creates a native SQL query.
public Doctrine\ORM\Query createQuery(mixed dql, string The)
Creates a new Query object.
public QueryBuilder createQueryBuilder()
Create a QueryBuilder instance
public void detach(object entity)
Detaches an entity from the EntityManager, causing a managed entity to become detached. Unflushed changes made to the entity if any (including removal of the entity), will not be synchronized to the database. Entities which previously referenced the detached entity will continue to reference it.
public object find(string entityName, mixed identifier)
Finds an Entity by its identifier.
This is just a convenient shortcut for getRepository($entityName)->find($id).
public void flush()
Flushes all changes to objects that have been queued up to now to the database. This effectively synchronizes the in-memory state of managed objects with the database.
public Doctrine\ORM\Mapping\ClassMetadata getClassMetadata(mixed className)
Returns the metadata for a class.
public Doctrine\ORM\Configuration getConfiguration()
Gets the Configuration used by the EntityManager.
public Doctrine\DBAL\Connection getConnection()
Gets the database connection object used by the EntityManager.
public Doctrine\Common\EventManager getEventManager()
Gets the EventManager used by the EntityManager.
public ExpressionBuilder getExpressionBuilder()
Gets an ExpressionBuilder used for object-oriented construction of query expressions.
Example:
[php] $qb = $em->createQueryBuilder(); $expr = $em->getExpressionBuilder(); $qb->select('u')->from('User', 'u') ->where($expr->orX($expr->eq('u.id', 1), $expr->eq('u.id', 2)));
public Doctrine\ORM\Internal\Hydration\AbstractHydrator getHydrator(int hydrationMode)
Gets a hydrator for the given hydration mode.
This method caches the hydrator instances which is used for all queries that don't selectively iterate over the result.
public Doctrine\ORM\Mapping\ClassMetadataFactory getMetadataFactory()
Gets the metadata factory used to gather the metadata of classes.
public ProxyFactory getProxyFactory()
Gets the proxy factory used by the EntityManager to create entity proxies.
public object getReference(mixed entityName, mixed identifier)
Gets a reference to the entity identified by the given type and identifier without actually loading it.
If partial objects are allowed, this method will return a partial object that only has its identifier populated. Otherwise a proxy is returned that automatically loads itself on first access.
public EntityRepository getRepository(string entityName)
Gets the repository for an entity class.
public Doctrine\ORM\UnitOfWork getUnitOfWork()
Gets the UnitOfWork used by the EntityManager to coordinate operations.
public object merge(object entity)
Merges the state of a detached entity into the persistence context of this EntityManager and returns the managed copy of the entity. The entity passed to merge will not become associated/managed with this EntityManager.
public Doctrine\ORM\Internal\Hydration\AbstractHydrator newHydrator(int hydrationMode)
Create a new instance for the given hydration mode.
public void persist(mixed entity, object object)
Tells the EntityManager to make an instance managed and persistent.
The entity will be entered into the database at or before transaction commit or as a result of the flush operation.
NOTE: The persist operation always considers entities that are not yet known to this EntityManager as NEW. Do not pass detached entities to the persist operation.
public void refresh(object entity)
Refreshes the persistent state of an entity from the database, overriding any local changes that have not yet been persisted.
public void remove(object entity)
Removes an entity instance.
A removed entity will be removed from the database at or before transaction commit or as a result of the flush operation.
public void rollback()
Performs a rollback on the underlying database connection and closes the EntityManager as it may now be in a corrupted state.
The EntityManager is the central access point to ORM functionality.