PHP 클래스 Doctrine\ORM\EntityManager

부터: 2.0
저자: Roman Borschel ([email protected])
파일 보기 프로젝트 열기: pmjones/php-framework-benchmarks 1 사용 예제들

공개 메소드들

메소드 설명
beginTransaction ( ) Starts a transaction on the underlying database connection.
clear ( string $entityName = null ) Clears the EntityManager. All entities that are currently managed by this EntityManager become detached.
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.
commit ( ) Commits a transaction on the underlying database connection.
contains ( object $entity ) : boolean Determines whether an entity instance is managed in this EntityManager.
copy ( object $entity, $deep = false ) : object Creates a copy of the given entity. Can create a shallow or a deep copy.
create ( mixed $conn, Doctrine\ORM\Configuration $config, Doctrine\Common\EventManager $eventManager = null ) : EntityManager Factory method to create EntityManager instances.
createNamedNativeQuery ( string $name ) : Doctrine\ORM\NativeQuery Creates a NativeQuery from a named native query.
createNamedQuery ( string $name ) : Doctrine\ORM\Query Creates a Query from a named query.
createNativeQuery ( string $sql, Doctrine\ORM\Query\ResultSetMapping $rsm ) : Doctrine\ORM\NativeQuery Creates a native SQL query.
createQuery ( $dql = "" ) : Doctrine\ORM\Query Creates a new Query object.
createQueryBuilder ( ) : Doctrine\ORM\QueryBuilder Create a QueryBuilder instance
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.
find ( string $entityName, mixed $identifier, integer $lockMode = LockMode::NONE, integer $lockVersion = null ) : object Finds an Entity by its identifier.
flush ( ) Flushes all changes to objects that have been queued up to now to the database.
getClassMetadata ( $className ) : Doctrine\ORM\Mapping\ClassMetadata Returns the ORM metadata descriptor for a class.
getConfiguration ( ) : Doctrine\ORM\Configuration Gets the Configuration used by the EntityManager.
getConnection ( ) : Doctrine\DBAL\Connection Gets the database connection object used by the EntityManager.
getEventManager ( ) : Doctrine\Common\EventManager Gets the EventManager used by the EntityManager.
getExpressionBuilder ( ) : ExpressionBuilder Gets an ExpressionBuilder used for object-oriented construction of query expressions.
getHydrator ( integer $hydrationMode ) : Doctrine\ORM\Internal\Hydration\AbstractHydrator Gets a hydrator for the given hydration mode.
getMetadataFactory ( ) : Doctrine\ORM\Mapping\ClassMetadataFactory Gets the metadata factory used to gather the metadata of classes.
getPartialReference ( string $entityName, mixed $identifier ) : object Gets a partial reference to the entity identified by the given type and identifier without actually loading it, if the entity is not yet loaded.
getProxyFactory ( ) : Doctrine\ORM\Proxy\ProxyFactory Gets the proxy factory used by the EntityManager to create entity proxies.
getReference ( string $entityName, mixed $identifier ) : object Gets a reference to the entity identified by the given type and identifier without actually loading it, if the entity is not yet loaded.
getRepository ( string $entityName ) : Doctrine\ORM\EntityRepository Gets the repository for an entity class.
getUnitOfWork ( ) : Doctrine\ORM\UnitOfWork Gets the UnitOfWork used by the EntityManager to coordinate operations.
lock ( object $entity, integer $lockMode, integer $lockVersion = null ) Acquire a lock on the given entity.
merge ( object $entity ) : object Merges the state of a detached entity into the persistence context of this EntityManager and returns the managed copy of the entity.
newHydrator ( integer $hydrationMode ) : Doctrine\ORM\Internal\Hydration\AbstractHydrator Create a new instance for the given hydration mode.
persist ( $entity ) Tells the EntityManager to make an instance managed and persistent.
refresh ( object $entity ) Refreshes the persistent state of an entity from the database, overriding any local changes that have not yet been persisted.
remove ( object $entity ) Removes an entity instance.
rollback ( ) Performs a rollback on the underlying database connection.
transactional ( Closur\Closure $func ) Executes a function in a transaction.

보호된 메소드들

메소드 설명
__construct ( 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.

비공개 메소드들

메소드 설명
errorIfClosed ( ) Throws an exception if the EntityManager is closed or currently not active.

메소드 상세

__construct() 보호된 메소드

Creates a new EntityManager that operates on the given database connection and uses the given Configuration and EventManager implementations.
protected __construct ( Doctrine\DBAL\Connection $conn, Doctrine\ORM\Configuration $config, Doctrine\Common\EventManager $eventManager )
$conn Doctrine\DBAL\Connection
$config Doctrine\ORM\Configuration
$eventManager Doctrine\Common\EventManager

beginTransaction() 공개 메소드

Starts a transaction on the underlying database connection.
사용 중단: Use {@link getConnection}.beginTransaction().
public beginTransaction ( )

clear() 공개 메소드

Clears the EntityManager. All entities that are currently managed by this EntityManager become detached.
public clear ( string $entityName = null )
$entityName string

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 close ( )

commit() 공개 메소드

Commits a transaction on the underlying database connection.
사용 중단: Use {@link getConnection}.commit().
public commit ( )

contains() 공개 메소드

Determines whether an entity instance is managed in this EntityManager.
public contains ( object $entity ) : boolean
$entity object
리턴 boolean TRUE if this EntityManager currently manages the given entity, FALSE otherwise.

copy() 공개 메소드

Creates a copy of the given entity. Can create a shallow or a deep copy.
public copy ( object $entity, $deep = false ) : object
$entity object The entity to copy.
리턴 object The new entity.

create() 공개 정적인 메소드

Factory method to create EntityManager instances.
public static create ( mixed $conn, Doctrine\ORM\Configuration $config, Doctrine\Common\EventManager $eventManager = null ) : EntityManager
$conn mixed An array with the connection parameters or an existing Connection instance.
$config Doctrine\ORM\Configuration The Configuration instance to use.
$eventManager Doctrine\Common\EventManager The EventManager instance to use.
리턴 EntityManager The created EntityManager.

createNamedNativeQuery() 공개 메소드

Creates a NativeQuery from a named native query.
public createNamedNativeQuery ( string $name ) : Doctrine\ORM\NativeQuery
$name string
리턴 Doctrine\ORM\NativeQuery

createNamedQuery() 공개 메소드

Creates a Query from a named query.
public createNamedQuery ( string $name ) : Doctrine\ORM\Query
$name string
리턴 Doctrine\ORM\Query

createNativeQuery() 공개 메소드

Creates a native SQL query.
public createNativeQuery ( string $sql, Doctrine\ORM\Query\ResultSetMapping $rsm ) : Doctrine\ORM\NativeQuery
$sql string
$rsm Doctrine\ORM\Query\ResultSetMapping The ResultSetMapping to use.
리턴 Doctrine\ORM\NativeQuery

createQuery() 공개 메소드

Creates a new Query object.
public createQuery ( $dql = "" ) : Doctrine\ORM\Query
리턴 Doctrine\ORM\Query

createQueryBuilder() 공개 메소드

Create a QueryBuilder instance
public createQueryBuilder ( ) : Doctrine\ORM\QueryBuilder
리턴 Doctrine\ORM\QueryBuilder $qb

detach() 공개 메소드

Entities which previously referenced the detached entity will continue to reference it.
public detach ( object $entity )
$entity object The entity to detach.

find() 공개 메소드

This is just a convenient shortcut for getRepository($entityName)->find($id).
public find ( string $entityName, mixed $identifier, integer $lockMode = LockMode::NONE, integer $lockVersion = null ) : object
$entityName string
$identifier mixed
$lockMode integer
$lockVersion integer
리턴 object

flush() 공개 메소드

This effectively synchronizes the in-memory state of managed objects with the database.
public flush ( )

getClassMetadata() 공개 메소드

The class name must be the fully-qualified class name without a leading backslash (as it is returned by get_class($obj)) or an aliased class name. Examples: MyProject\Domain\User sales:PriceRequest
public getClassMetadata ( $className ) : Doctrine\ORM\Mapping\ClassMetadata
리턴 Doctrine\ORM\Mapping\ClassMetadata

getConfiguration() 공개 메소드

Gets the Configuration used by the EntityManager.
public getConfiguration ( ) : Doctrine\ORM\Configuration
리턴 Doctrine\ORM\Configuration

getConnection() 공개 메소드

Gets the database connection object used by the EntityManager.
public getConnection ( ) : Doctrine\DBAL\Connection
리턴 Doctrine\DBAL\Connection

getEventManager() 공개 메소드

Gets the EventManager used by the EntityManager.
public getEventManager ( ) : Doctrine\Common\EventManager
리턴 Doctrine\Common\EventManager

getExpressionBuilder() 공개 메소드

Example: $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 getExpressionBuilder ( ) : ExpressionBuilder
리턴 ExpressionBuilder

getHydrator() 공개 메소드

This method caches the hydrator instances which is used for all queries that don't selectively iterate over the result.
public getHydrator ( integer $hydrationMode ) : Doctrine\ORM\Internal\Hydration\AbstractHydrator
$hydrationMode integer
리턴 Doctrine\ORM\Internal\Hydration\AbstractHydrator

getMetadataFactory() 공개 메소드

Gets the metadata factory used to gather the metadata of classes.
public getMetadataFactory ( ) : Doctrine\ORM\Mapping\ClassMetadataFactory
리턴 Doctrine\ORM\Mapping\ClassMetadataFactory

getPartialReference() 공개 메소드

The returned reference may be a partial object if the entity is not yet loaded/managed. If it is a partial object it will not initialize the rest of the entity state on access. Thus you can only ever safely access the identifier of an entity obtained through this method. The use-cases for partial references involve maintaining bidirectional associations without loading one side of the association or to update an entity without loading it. Note, however, that in the latter case the original (persistent) entity data will never be visible to the application (especially not event listeners) as it will never be loaded in the first place.
public getPartialReference ( string $entityName, mixed $identifier ) : object
$entityName string The name of the entity type.
$identifier mixed The entity identifier.
리턴 object The (partial) entity reference.

getProxyFactory() 공개 메소드

Gets the proxy factory used by the EntityManager to create entity proxies.
public getProxyFactory ( ) : Doctrine\ORM\Proxy\ProxyFactory
리턴 Doctrine\ORM\Proxy\ProxyFactory

getReference() 공개 메소드

Gets a reference to the entity identified by the given type and identifier without actually loading it, if the entity is not yet loaded.
public getReference ( string $entityName, mixed $identifier ) : object
$entityName string The name of the entity type.
$identifier mixed The entity identifier.
리턴 object The entity reference.

getRepository() 공개 메소드

Gets the repository for an entity class.
public getRepository ( string $entityName ) : Doctrine\ORM\EntityRepository
$entityName string The name of the entity.
리턴 Doctrine\ORM\EntityRepository The repository class.

getUnitOfWork() 공개 메소드

Gets the UnitOfWork used by the EntityManager to coordinate operations.
public getUnitOfWork ( ) : Doctrine\ORM\UnitOfWork
리턴 Doctrine\ORM\UnitOfWork

lock() 공개 메소드

Acquire a lock on the given entity.
public lock ( object $entity, integer $lockMode, integer $lockVersion = null )
$entity object
$lockMode integer
$lockVersion integer

merge() 공개 메소드

The entity passed to merge will not become associated/managed with this EntityManager.
public merge ( object $entity ) : object
$entity object The detached entity to merge into the persistence context.
리턴 object The managed copy of the entity.

newHydrator() 공개 메소드

Create a new instance for the given hydration mode.
public newHydrator ( integer $hydrationMode ) : Doctrine\ORM\Internal\Hydration\AbstractHydrator
$hydrationMode integer
리턴 Doctrine\ORM\Internal\Hydration\AbstractHydrator

persist() 공개 메소드

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 persist ( $entity )

refresh() 공개 메소드

Refreshes the persistent state of an entity from the database, overriding any local changes that have not yet been persisted.
public refresh ( object $entity )
$entity object The entity to refresh.

remove() 공개 메소드

A removed entity will be removed from the database at or before transaction commit or as a result of the flush operation.
public remove ( object $entity )
$entity object The entity instance to remove.

rollback() 공개 메소드

Performs a rollback on the underlying database connection.
사용 중단: Use {@link getConnection}.rollback().
public rollback ( )

transactional() 공개 메소드

The function gets passed this EntityManager instance as an (optional) parameter. {@link flush} is invoked prior to transaction commit. If an exception occurs during execution of the function or flushing or transaction commit, the transaction is rolled back, the EntityManager closed and the exception re-thrown.
public transactional ( Closur\Closure $func )
$func Closur\Closure The function to execute transactionally.