Merge branch 'TrailingWhitespaces'
This commit is contained in:
commit
6c4aaab2d6
@ -616,7 +616,7 @@ abstract class AbstractQuery
|
||||
$this->_queryCacheProfile = $this->_queryCacheProfile
|
||||
? $this->_queryCacheProfile->setCacheKey($id)
|
||||
: new QueryCacheProfile(0, $id);
|
||||
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
|
@ -523,14 +523,14 @@ class Configuration extends \Doctrine\DBAL\Configuration
|
||||
|
||||
/**
|
||||
* Set default repository class.
|
||||
*
|
||||
*
|
||||
* @since 2.2
|
||||
* @param string $className
|
||||
* @throws ORMException If not is a \Doctrine\ORM\EntityRepository
|
||||
*/
|
||||
public function setDefaultRepositoryClassName($className)
|
||||
{
|
||||
if ($className != "Doctrine\ORM\EntityRepository" &&
|
||||
if ($className != "Doctrine\ORM\EntityRepository" &&
|
||||
!is_subclass_of($className, 'Doctrine\ORM\EntityRepository')){
|
||||
throw ORMException::invalidEntityRepository($className);
|
||||
}
|
||||
@ -539,7 +539,7 @@ class Configuration extends \Doctrine\DBAL\Configuration
|
||||
|
||||
/**
|
||||
* Get default repository class.
|
||||
*
|
||||
*
|
||||
* @since 2.2
|
||||
* @return string
|
||||
*/
|
||||
|
@ -42,10 +42,10 @@ class LifecycleEventArgs extends EventArgs
|
||||
* @var object
|
||||
*/
|
||||
private $entity;
|
||||
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
*
|
||||
* @param object $entity
|
||||
* @param \Doctrine\ORM\EntityManager $em
|
||||
*/
|
||||
@ -54,11 +54,11 @@ class LifecycleEventArgs extends EventArgs
|
||||
$this->entity = $entity;
|
||||
$this->em = $em;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Retireve associated Entity.
|
||||
*
|
||||
* @return object
|
||||
*
|
||||
* @return object
|
||||
*/
|
||||
public function getEntity()
|
||||
{
|
||||
@ -67,7 +67,7 @@ class LifecycleEventArgs extends EventArgs
|
||||
|
||||
/**
|
||||
* Retrieve associated EntityManager.
|
||||
*
|
||||
*
|
||||
* @return \Doctrine\ORM\EntityManager
|
||||
*/
|
||||
public function getEntityManager()
|
||||
|
@ -43,7 +43,7 @@ class LoadClassMetadataEventArgs extends EventArgs
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*
|
||||
*
|
||||
* @param \Doctrine\ORM\Mapping\ClassMetadataInfo $classMetadata
|
||||
* @param \Doctrine\ORM\EntityManager $em
|
||||
*/
|
||||
@ -55,7 +55,7 @@ class LoadClassMetadataEventArgs extends EventArgs
|
||||
|
||||
/**
|
||||
* Retrieve associated ClassMetadata.
|
||||
*
|
||||
*
|
||||
* @return \Doctrine\ORM\Mapping\ClassMetadataInfo
|
||||
*/
|
||||
public function getClassMetadata()
|
||||
@ -65,7 +65,7 @@ class LoadClassMetadataEventArgs extends EventArgs
|
||||
|
||||
/**
|
||||
* Retrieve associated EntityManager.
|
||||
*
|
||||
*
|
||||
* @return \Doctrine\ORM\EntityManager
|
||||
*/
|
||||
public function getEntityManager()
|
||||
|
@ -42,7 +42,7 @@ class OnClearEventArgs extends \Doctrine\Common\EventArgs
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*
|
||||
*
|
||||
* @param \Doctrine\ORM\EntityManager $em
|
||||
* @param string $entityClass Optional entity class
|
||||
*/
|
||||
@ -54,7 +54,7 @@ class OnClearEventArgs extends \Doctrine\Common\EventArgs
|
||||
|
||||
/**
|
||||
* Retrieve associated EntityManager.
|
||||
*
|
||||
*
|
||||
* @return \Doctrine\ORM\EntityManager
|
||||
*/
|
||||
public function getEntityManager()
|
||||
|
@ -38,13 +38,13 @@ class OnFlushEventArgs extends \Doctrine\Common\EventArgs
|
||||
* @var Doctirne\ORM\EntityManager
|
||||
*/
|
||||
private $em;
|
||||
|
||||
|
||||
//private $entitiesToPersist = array();
|
||||
//private $entitiesToRemove = array();
|
||||
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*
|
||||
*
|
||||
* @param \Doctrine\ORM\EntityManager $em
|
||||
*/
|
||||
public function __construct(EntityManager $em)
|
||||
@ -54,30 +54,30 @@ class OnFlushEventArgs extends \Doctrine\Common\EventArgs
|
||||
|
||||
/**
|
||||
* Retrieve associated EntityManager.
|
||||
*
|
||||
*
|
||||
* @return \Doctrine\ORM\EntityManager
|
||||
*/
|
||||
public function getEntityManager()
|
||||
{
|
||||
return $this->em;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
public function addEntityToPersist($entity)
|
||||
{
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
public function addEntityToRemove($entity)
|
||||
{
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
public function addEntityToUpdate($entity)
|
||||
{
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
public function getEntitiesToPersist()
|
||||
{
|
||||
return $this->_entitiesToPersist;
|
||||
|
@ -41,7 +41,7 @@ class PostFlushEventArgs extends EventArgs
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*
|
||||
*
|
||||
* @param \Doctrine\ORM\EntityManager $em
|
||||
*/
|
||||
public function __construct(EntityManager $em)
|
||||
@ -51,7 +51,7 @@ class PostFlushEventArgs extends EventArgs
|
||||
|
||||
/**
|
||||
* Retrieve associated EntityManager.
|
||||
*
|
||||
*
|
||||
* @return \Doctrine\ORM\EntityManager
|
||||
*/
|
||||
public function getEntityManager()
|
||||
|
@ -41,7 +41,7 @@ class PreUpdateEventArgs extends LifecycleEventArgs
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*
|
||||
*
|
||||
* @param object $entity
|
||||
* @param \Doctrine\ORM\EntityManager $em
|
||||
* @param array $changeSet
|
||||
@ -49,13 +49,13 @@ class PreUpdateEventArgs extends LifecycleEventArgs
|
||||
public function __construct($entity, EntityManager $em, array &$changeSet)
|
||||
{
|
||||
parent::__construct($entity, $em);
|
||||
|
||||
|
||||
$this->entityChangeSet = &$changeSet;
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve entity changeset.
|
||||
*
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function getEntityChangeSet()
|
||||
@ -75,7 +75,7 @@ class PreUpdateEventArgs extends LifecycleEventArgs
|
||||
|
||||
/**
|
||||
* Get the old value of the changeset of the changed field.
|
||||
*
|
||||
*
|
||||
* @param string $field
|
||||
* @return mixed
|
||||
*/
|
||||
@ -101,7 +101,7 @@ class PreUpdateEventArgs extends LifecycleEventArgs
|
||||
|
||||
/**
|
||||
* Set the new value of this field.
|
||||
*
|
||||
*
|
||||
* @param string $field
|
||||
* @param mixed $value
|
||||
*/
|
||||
@ -114,8 +114,8 @@ class PreUpdateEventArgs extends LifecycleEventArgs
|
||||
|
||||
/**
|
||||
* Assert the field exists in changeset.
|
||||
*
|
||||
* @param string $field
|
||||
*
|
||||
* @param string $field
|
||||
*/
|
||||
private function assertValidField($field)
|
||||
{
|
||||
|
@ -35,55 +35,55 @@ final class Events
|
||||
/**
|
||||
* The preRemove event occurs for a given entity before the respective
|
||||
* EntityManager remove operation for that entity is executed.
|
||||
*
|
||||
*
|
||||
* This is an entity lifecycle event.
|
||||
*
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
const preRemove = 'preRemove';
|
||||
/**
|
||||
* The postRemove event occurs for an entity after the entity has
|
||||
* The postRemove event occurs for an entity after the entity has
|
||||
* been deleted. It will be invoked after the database delete operations.
|
||||
*
|
||||
*
|
||||
* This is an entity lifecycle event.
|
||||
*
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
const postRemove = 'postRemove';
|
||||
/**
|
||||
* The prePersist event occurs for a given entity before the respective
|
||||
* EntityManager persist operation for that entity is executed.
|
||||
*
|
||||
*
|
||||
* This is an entity lifecycle event.
|
||||
*
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
const prePersist = 'prePersist';
|
||||
/**
|
||||
* The postPersist event occurs for an entity after the entity has
|
||||
* The postPersist event occurs for an entity after the entity has
|
||||
* been made persistent. It will be invoked after the database insert operations.
|
||||
* Generated primary key values are available in the postPersist event.
|
||||
*
|
||||
*
|
||||
* This is an entity lifecycle event.
|
||||
*
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
const postPersist = 'postPersist';
|
||||
/**
|
||||
* The preUpdate event occurs before the database update operations to
|
||||
* entity data.
|
||||
*
|
||||
* The preUpdate event occurs before the database update operations to
|
||||
* entity data.
|
||||
*
|
||||
* This is an entity lifecycle event.
|
||||
*
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
const preUpdate = 'preUpdate';
|
||||
/**
|
||||
* The postUpdate event occurs after the database update operations to
|
||||
* entity data.
|
||||
*
|
||||
* The postUpdate event occurs after the database update operations to
|
||||
* entity data.
|
||||
*
|
||||
* This is an entity lifecycle event.
|
||||
*
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
const postUpdate = 'postUpdate';
|
||||
@ -91,24 +91,24 @@ final class Events
|
||||
* The postLoad event occurs for an entity after the entity has been loaded
|
||||
* into the current EntityManager from the database or after the refresh operation
|
||||
* has been applied to it.
|
||||
*
|
||||
*
|
||||
* Note that the postLoad event occurs for an entity before any associations have been
|
||||
* initialized. Therefore it is not safe to access associations in a postLoad callback
|
||||
* or event handler.
|
||||
*
|
||||
*
|
||||
* This is an entity lifecycle event.
|
||||
*
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
const postLoad = 'postLoad';
|
||||
/**
|
||||
* The loadClassMetadata event occurs after the mapping metadata for a class
|
||||
* has been loaded from a mapping source (annotations/xml/yaml).
|
||||
*
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
const loadClassMetadata = 'loadClassMetadata';
|
||||
|
||||
|
||||
/**
|
||||
* The preFlush event occurs when the EntityManager#flush() operation is invoked,
|
||||
* but before any changes to managed entites have been calculated. This event is
|
||||
@ -122,7 +122,7 @@ final class Events
|
||||
* actual database operations are executed. The event is only raised if there is
|
||||
* actually something to do for the underlying UnitOfWork. If nothing needs to be done,
|
||||
* the onFlush event is not raised.
|
||||
*
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
const onFlush = 'onFlush';
|
||||
@ -133,11 +133,11 @@ final class Events
|
||||
* actually something to do for the underlying UnitOfWork. If nothing needs to be done,
|
||||
* the postFlush event is not raised. The event won't be raised if an error occurs during the
|
||||
* flush operation.
|
||||
*
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
const postFlush = 'postFlush';
|
||||
|
||||
|
||||
/**
|
||||
* The onClear event occurs when the EntityManager#clear() operation is invoked,
|
||||
* after all references to entities have been removed from the unit of work.
|
||||
|
@ -35,7 +35,7 @@ abstract class AbstractIdGenerator
|
||||
* Gets whether this generator is a post-insert generator which means that
|
||||
* {@link generate()} must be called after the entity has been inserted
|
||||
* into the database.
|
||||
*
|
||||
*
|
||||
* By default, this method returns FALSE. Generators that have this requirement
|
||||
* must override this method and return TRUE.
|
||||
*
|
||||
|
@ -46,14 +46,14 @@ class AssignedGenerator extends AbstractIdGenerator
|
||||
$class = $em->getClassMetadata(get_class($entity));
|
||||
$idFields = $class->getIdentifierFieldNames();
|
||||
$identifier = array();
|
||||
|
||||
|
||||
foreach ($idFields as $idField) {
|
||||
$value = $class->reflFields[$idField]->getValue($entity);
|
||||
|
||||
|
||||
if ( ! isset($value)) {
|
||||
throw ORMException::entityMissingAssignedIdForField($entity, $idField);
|
||||
}
|
||||
|
||||
|
||||
if (isset($class->associationMappings[$idField])) {
|
||||
if ( ! $em->getUnitOfWork()->isInIdentityMap($value)) {
|
||||
throw ORMException::entityMissingForeignAssignedId($entity, $value);
|
||||
@ -62,10 +62,10 @@ class AssignedGenerator extends AbstractIdGenerator
|
||||
// NOTE: Single Columns as associated identifiers only allowed - this constraint it is enforced.
|
||||
$value = current($em->getUnitOfWork()->getEntityIdentifier($value));
|
||||
}
|
||||
|
||||
|
||||
$identifier[$idField] = $value;
|
||||
}
|
||||
|
||||
|
||||
return $identifier;
|
||||
}
|
||||
}
|
||||
|
@ -50,12 +50,12 @@ class TableGenerator extends AbstractIdGenerator
|
||||
if ($this->_maxValue === null || $this->_nextValue == $this->_maxValue) {
|
||||
// Allocate new values
|
||||
$conn = $em->getConnection();
|
||||
|
||||
|
||||
if ($conn->getTransactionNestingLevel() === 0) {
|
||||
// use select for update
|
||||
$sql = $conn->getDatabasePlatform()->getTableHiLoCurrentValSql($this->_tableName, $this->_sequenceName);
|
||||
$currentLevel = $conn->fetchColumn($sql);
|
||||
|
||||
|
||||
if ($currentLevel != null) {
|
||||
$this->_nextValue = $currentLevel;
|
||||
$this->_maxValue = $this->_nextValue + $this->_allocationSize;
|
||||
@ -63,7 +63,7 @@ class TableGenerator extends AbstractIdGenerator
|
||||
$updateSql = $conn->getDatabasePlatform()->getTableHiLoUpdateNextValSql(
|
||||
$this->_tableName, $this->_sequenceName, $this->_allocationSize
|
||||
);
|
||||
|
||||
|
||||
if ($conn->executeUpdate($updateSql, array(1 => $currentLevel, 2 => $currentLevel+1)) !== 1) {
|
||||
// no affected rows, concurrency issue, throw exception
|
||||
}
|
||||
@ -75,7 +75,7 @@ class TableGenerator extends AbstractIdGenerator
|
||||
// or do we want to work with table locks exclusively?
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return $this->_nextValue++;
|
||||
}
|
||||
}
|
@ -24,7 +24,7 @@ namespace Doctrine\ORM\Internal;
|
||||
* correct order in which changes to entities need to be persisted.
|
||||
*
|
||||
* @since 2.0
|
||||
* @author Roman Borschel <roman@code-factory.org>
|
||||
* @author Roman Borschel <roman@code-factory.org>
|
||||
* @author Guilherme Blanco <guilhermeblanco@hotmail.com>
|
||||
*/
|
||||
class CommitOrderCalculator
|
||||
@ -32,12 +32,12 @@ class CommitOrderCalculator
|
||||
const NOT_VISITED = 1;
|
||||
const IN_PROGRESS = 2;
|
||||
const VISITED = 3;
|
||||
|
||||
|
||||
private $_nodeStates = array();
|
||||
private $_classes = array(); // The nodes to sort
|
||||
private $_relatedClasses = array();
|
||||
private $_sorted = array();
|
||||
|
||||
|
||||
/**
|
||||
* Clears the current graph.
|
||||
*
|
||||
@ -48,10 +48,10 @@ class CommitOrderCalculator
|
||||
$this->_classes =
|
||||
$this->_relatedClasses = array();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Gets a valid commit order for all current nodes.
|
||||
*
|
||||
*
|
||||
* Uses a depth-first search (DFS) to traverse the graph.
|
||||
* The desired topological sorting is the reverse postorder of these searches.
|
||||
*
|
||||
@ -65,12 +65,12 @@ class CommitOrderCalculator
|
||||
if ($nodeCount <= 1) {
|
||||
return ($nodeCount == 1) ? array_values($this->_classes) : array();
|
||||
}
|
||||
|
||||
|
||||
// Init
|
||||
foreach ($this->_classes as $node) {
|
||||
$this->_nodeStates[$node->name] = self::NOT_VISITED;
|
||||
}
|
||||
|
||||
|
||||
// Go
|
||||
foreach ($this->_classes as $node) {
|
||||
if ($this->_nodeStates[$node->name] == self::NOT_VISITED) {
|
||||
@ -100,17 +100,17 @@ class CommitOrderCalculator
|
||||
$this->_nodeStates[$node->name] = self::VISITED;
|
||||
$this->_sorted[] = $node;
|
||||
}
|
||||
|
||||
|
||||
public function addDependency($fromClass, $toClass)
|
||||
{
|
||||
$this->_relatedClasses[$fromClass->name][] = $toClass;
|
||||
}
|
||||
|
||||
|
||||
public function hasClass($className)
|
||||
{
|
||||
return isset($this->_classes[$className]);
|
||||
}
|
||||
|
||||
|
||||
public function addClass($class)
|
||||
{
|
||||
$this->_classes[$class->name] = $class;
|
||||
|
@ -233,20 +233,20 @@ class ObjectHydrator extends AbstractHydrator
|
||||
}
|
||||
|
||||
$this->_hints['fetchAlias'] = $dqlAlias;
|
||||
|
||||
|
||||
$entity = $this->_uow->createEntity($className, $data, $this->_hints);
|
||||
|
||||
|
||||
//TODO: These should be invoked later, after hydration, because associations may not yet be loaded here.
|
||||
if (isset($this->_ce[$className]->lifecycleCallbacks[Events::postLoad])) {
|
||||
$this->_ce[$className]->invokeLifecycleCallbacks(Events::postLoad, $entity);
|
||||
}
|
||||
|
||||
|
||||
$evm = $this->_em->getEventManager();
|
||||
|
||||
if ($evm->hasListeners(Events::postLoad)) {
|
||||
$evm->dispatchEvent(Events::postLoad, new LifecycleEventArgs($entity, $this->_em));
|
||||
}
|
||||
|
||||
|
||||
return $entity;
|
||||
}
|
||||
|
||||
|
@ -32,22 +32,22 @@ use Doctrine\DBAL\Connection;
|
||||
*/
|
||||
class ScalarHydrator extends AbstractHydrator
|
||||
{
|
||||
/**
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function hydrateAllData()
|
||||
{
|
||||
$result = array();
|
||||
$cache = array();
|
||||
|
||||
|
||||
while ($data = $this->_stmt->fetch(\PDO::FETCH_ASSOC)) {
|
||||
$this->hydrateRowData($data, $cache, $result);
|
||||
}
|
||||
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function hydrateRowData(array $data, array &$cache, array &$result)
|
||||
|
@ -63,18 +63,18 @@ class SimpleObjectHydrator extends AbstractHydrator
|
||||
if (count($this->_rsm->aliasMap) !== 1) {
|
||||
throw new \RuntimeException("Cannot use SimpleObjectHydrator with a ResultSetMapping that contains more than one object result.");
|
||||
}
|
||||
|
||||
|
||||
if ($this->_rsm->scalarMappings) {
|
||||
throw new \RuntimeException("Cannot use SimpleObjectHydrator with a ResultSetMapping that contains scalar mappings.");
|
||||
}
|
||||
|
||||
|
||||
$this->class = $this->_em->getClassMetadata(reset($this->_rsm->aliasMap));
|
||||
|
||||
|
||||
// We only need to add declaring classes if we have inheritance.
|
||||
if ($this->class->inheritanceType === ClassMetadata::INHERITANCE_TYPE_NONE) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
foreach ($this->_rsm->declaringClasses AS $column => $class) {
|
||||
$this->declaringClasses[$column] = $this->_em->getClassMetadata($class);
|
||||
}
|
||||
@ -87,27 +87,27 @@ class SimpleObjectHydrator extends AbstractHydrator
|
||||
{
|
||||
$entityName = $this->class->name;
|
||||
$data = array();
|
||||
|
||||
|
||||
// We need to find the correct entity class name if we have inheritance in resultset
|
||||
if ($this->class->inheritanceType !== ClassMetadata::INHERITANCE_TYPE_NONE) {
|
||||
$discrColumnName = $this->_platform->getSQLResultCasing($this->class->discriminatorColumn['name']);
|
||||
|
||||
|
||||
if ($sqlResult[$discrColumnName] === '') {
|
||||
throw HydrationException::emptyDiscriminatorValue(key($this->_rsm->aliasMap));
|
||||
}
|
||||
|
||||
$entityName = $this->class->discriminatorMap[$sqlResult[$discrColumnName]];
|
||||
|
||||
|
||||
unset($sqlResult[$discrColumnName]);
|
||||
}
|
||||
|
||||
|
||||
foreach ($sqlResult as $column => $value) {
|
||||
// Hydrate column information if not yet present
|
||||
if ( ! isset($cache[$column])) {
|
||||
if (($info = $this->hydrateColumnInfo($entityName, $column)) === null) {
|
||||
continue;
|
||||
}
|
||||
|
||||
|
||||
$cache[$column] = $info;
|
||||
}
|
||||
|
||||
@ -116,7 +116,7 @@ class SimpleObjectHydrator extends AbstractHydrator
|
||||
$type = Type::getType($cache[$column]['class']->fieldMappings[$cache[$column]['name']]['type']);
|
||||
$value = $type->convertToPHPValue($value, $this->_platform);
|
||||
}
|
||||
|
||||
|
||||
// Prevent overwrite in case of inherit classes using same property name (See AbstractHydrator)
|
||||
if (isset($cache[$column]) && ( ! isset($data[$cache[$column]['name']]) || $value !== null)) {
|
||||
$data[$cache[$column]['name']] = $value;
|
||||
@ -129,7 +129,7 @@ class SimpleObjectHydrator extends AbstractHydrator
|
||||
|
||||
$uow = $this->_em->getUnitOfWork();
|
||||
$entity = $uow->createEntity($entityName, $data, $this->_hints);
|
||||
|
||||
|
||||
//TODO: These should be invoked later, after hydration, because associations may not yet be loaded here.
|
||||
if (isset($this->class->lifecycleCallbacks[Events::postLoad])) {
|
||||
$this->class->invokeLifecycleCallbacks(Events::postLoad, $entity);
|
||||
@ -140,24 +140,24 @@ class SimpleObjectHydrator extends AbstractHydrator
|
||||
if ($evm->hasListeners(Events::postLoad)) {
|
||||
$evm->dispatchEvent(Events::postLoad, new LifecycleEventArgs($entity, $this->_em));
|
||||
}
|
||||
|
||||
|
||||
$result[] = $entity;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Retrieve column information form ResultSetMapping.
|
||||
*
|
||||
*
|
||||
* @param string $entityName
|
||||
* @param string $column
|
||||
*
|
||||
* @return array
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
protected function hydrateColumnInfo($entityName, $column)
|
||||
{
|
||||
switch (true) {
|
||||
case (isset($this->_rsm->fieldMappings[$column])):
|
||||
$class = isset($this->declaringClasses[$column])
|
||||
? $this->declaringClasses[$column]
|
||||
$class = isset($this->declaringClasses[$column])
|
||||
? $this->declaringClasses[$column]
|
||||
: $this->class;
|
||||
|
||||
// If class is not part of the inheritance, ignore
|
||||
@ -172,8 +172,8 @@ class SimpleObjectHydrator extends AbstractHydrator
|
||||
);
|
||||
|
||||
case (isset($this->_rsm->relationMap[$column])):
|
||||
$class = isset($this->_rsm->relationMap[$column])
|
||||
? $this->_rsm->relationMap[$column]
|
||||
$class = isset($this->_rsm->relationMap[$column])
|
||||
? $this->_rsm->relationMap[$column]
|
||||
: $this->class;
|
||||
|
||||
// If class is not self referencing, ignore
|
||||
@ -181,7 +181,7 @@ class SimpleObjectHydrator extends AbstractHydrator
|
||||
return null;
|
||||
}
|
||||
|
||||
// TODO: Decide what to do with associations. It seems original code is incomplete.
|
||||
// TODO: Decide what to do with associations. It seems original code is incomplete.
|
||||
// One solution is to load the association, but it might require extra efforts.
|
||||
return array('name' => $column);
|
||||
|
||||
|
@ -33,24 +33,24 @@ use Doctrine\DBAL\Connection,
|
||||
class SingleScalarHydrator extends AbstractHydrator
|
||||
{
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function hydrateAllData()
|
||||
{
|
||||
$data = $this->_stmt->fetchAll(\PDO::FETCH_ASSOC);
|
||||
$numRows = count($data);
|
||||
|
||||
|
||||
if ($numRows === 0) {
|
||||
throw new NoResultException();
|
||||
}
|
||||
|
||||
|
||||
if ($numRows > 1 || count($data[key($data)]) > 1) {
|
||||
throw new NonUniqueResultException();
|
||||
}
|
||||
|
||||
|
||||
$cache = array();
|
||||
$result = $this->gatherScalarRowData($data[key($data)], $cache);
|
||||
|
||||
|
||||
return array_shift($result);
|
||||
}
|
||||
}
|
@ -124,7 +124,7 @@ class AssociationBuilder
|
||||
|
||||
/**
|
||||
* Add Join Columns
|
||||
*
|
||||
*
|
||||
* @param string $columnName
|
||||
* @param string $referencedColumnName
|
||||
* @param bool $nullable
|
||||
|
@ -62,7 +62,7 @@ class ClassMetadataBuilder
|
||||
public function setMappedSuperClass()
|
||||
{
|
||||
$this->cm->isMappedSuperclass = true;
|
||||
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
|
@ -170,7 +170,7 @@ class FieldBuilder
|
||||
|
||||
/**
|
||||
* Set Sequence Generator
|
||||
*
|
||||
*
|
||||
* @param string $sequenceName
|
||||
* @param int $allocationSize
|
||||
* @param int $initialValue
|
||||
@ -188,7 +188,7 @@ class FieldBuilder
|
||||
|
||||
/**
|
||||
* Set column definition.
|
||||
*
|
||||
*
|
||||
* @param string $def
|
||||
* @return FieldBuilder
|
||||
*/
|
||||
|
@ -358,7 +358,7 @@ class ClassMetadata extends ClassMetadataInfo implements IClassMetadata
|
||||
($this->reflClass->getMethod($callback)->getModifiers() & \ReflectionMethod::IS_PUBLIC) == 0) {
|
||||
throw MappingException::lifecycleCallbackMethodNotFound($this->name, $callback);
|
||||
}
|
||||
|
||||
|
||||
return parent::addLifecycleCallback($callback, $event);
|
||||
}
|
||||
}
|
||||
|
@ -43,7 +43,7 @@ class ClassMetadataFactory implements ClassMetadataFactoryInterface
|
||||
* @var EntityManager
|
||||
*/
|
||||
private $em;
|
||||
|
||||
|
||||
/**
|
||||
* @var AbstractPlatform
|
||||
*/
|
||||
@ -73,7 +73,7 @@ class ClassMetadataFactory implements ClassMetadataFactoryInterface
|
||||
* @var bool
|
||||
*/
|
||||
private $initialized = false;
|
||||
|
||||
|
||||
/**
|
||||
* @param EntityManager $$em
|
||||
*/
|
||||
@ -101,16 +101,16 @@ class ClassMetadataFactory implements ClassMetadataFactoryInterface
|
||||
{
|
||||
return $this->cacheDriver;
|
||||
}
|
||||
|
||||
|
||||
public function getLoadedMetadata()
|
||||
{
|
||||
return $this->loadedMetadata;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Forces the factory to load the metadata of all classes known to the underlying
|
||||
* mapping driver.
|
||||
*
|
||||
*
|
||||
* @return array The ClassMetadata instances of all mapped classes.
|
||||
*/
|
||||
public function getAllMetadata()
|
||||
@ -188,7 +188,7 @@ class ClassMetadataFactory implements ClassMetadataFactoryInterface
|
||||
|
||||
/**
|
||||
* Checks whether the factory has the metadata for a class loaded already.
|
||||
*
|
||||
*
|
||||
* @param string $className
|
||||
* @return boolean TRUE if the metadata of the class in question is already loaded, FALSE otherwise.
|
||||
*/
|
||||
@ -199,7 +199,7 @@ class ClassMetadataFactory implements ClassMetadataFactoryInterface
|
||||
|
||||
/**
|
||||
* Sets the metadata descriptor for a specific class.
|
||||
*
|
||||
*
|
||||
* NOTE: This is only useful in very special cases, like when generating proxy classes.
|
||||
*
|
||||
* @param string $className
|
||||
@ -308,11 +308,11 @@ class ClassMetadataFactory implements ClassMetadataFactoryInterface
|
||||
if ($parent && $parent->isInheritanceTypeSingleTable()) {
|
||||
$class->setPrimaryTable($parent->table);
|
||||
}
|
||||
|
||||
|
||||
if ($parent && $parent->containsForeignIdentifier) {
|
||||
$class->containsForeignIdentifier = true;
|
||||
}
|
||||
|
||||
|
||||
if ($parent && !empty ($parent->namedQueries)) {
|
||||
$this->addInheritedNamedQueries($class, $parent);
|
||||
}
|
||||
@ -325,7 +325,7 @@ class ClassMetadataFactory implements ClassMetadataFactoryInterface
|
||||
}
|
||||
|
||||
$this->validateRuntimeMetadata($class, $parent);
|
||||
|
||||
|
||||
$this->loadedMetadata[$className] = $class;
|
||||
|
||||
$parent = $class;
|
||||
@ -436,10 +436,10 @@ class ClassMetadataFactory implements ClassMetadataFactoryInterface
|
||||
$subClass->addInheritedAssociationMapping($mapping);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Adds inherited named queries to the subclass mapping.
|
||||
*
|
||||
*
|
||||
* @since 2.2
|
||||
* @param \Doctrine\ORM\Mapping\ClassMetadata $subClass
|
||||
* @param \Doctrine\ORM\Mapping\ClassMetadata $parentClass
|
||||
@ -524,13 +524,13 @@ class ClassMetadataFactory implements ClassMetadataFactoryInterface
|
||||
if ( ! $this->initialized) {
|
||||
$this->initialize();
|
||||
}
|
||||
|
||||
|
||||
// Check for namespace alias
|
||||
if (strpos($class, ':') !== false) {
|
||||
list($namespaceAlias, $simpleClassName) = explode(':', $class);
|
||||
$class = $this->em->getConfiguration()->getEntityNamespace($namespaceAlias) . '\\' . $simpleClassName;
|
||||
}
|
||||
|
||||
|
||||
return $this->driver->isTransient($class);
|
||||
}
|
||||
}
|
||||
|
@ -25,7 +25,7 @@ use Doctrine\ORM\Mapping\MappingException;
|
||||
|
||||
/**
|
||||
* Base driver for file-based metadata drivers.
|
||||
*
|
||||
*
|
||||
* A file driver operates in a mode where it loads the mapping files of individual
|
||||
* classes on demand. This requires the user to adhere to the convention of 1 mapping
|
||||
* file per class and the file names of the mapping files must correspond to the full
|
||||
@ -56,16 +56,16 @@ abstract class AbstractFileDriver implements Driver
|
||||
*/
|
||||
protected $_fileExtension;
|
||||
|
||||
/**
|
||||
* Initializes a new FileDriver that looks in the given path(s) for mapping
|
||||
* documents and operates in the specified operating mode.
|
||||
*
|
||||
* @param string|array $paths One or multiple paths where mapping documents can be found.
|
||||
*/
|
||||
public function __construct($paths)
|
||||
{
|
||||
/**
|
||||
* Initializes a new FileDriver that looks in the given path(s) for mapping
|
||||
* documents and operates in the specified operating mode.
|
||||
*
|
||||
* @param string|array $paths One or multiple paths where mapping documents can be found.
|
||||
*/
|
||||
public function __construct($paths)
|
||||
{
|
||||
$this->addPaths((array) $paths);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Append lookup paths to metadata driver.
|
||||
@ -117,7 +117,7 @@ abstract class AbstractFileDriver implements Driver
|
||||
public function getElement($className)
|
||||
{
|
||||
$result = $this->_loadMappingFile($this->_findMappingFile($className));
|
||||
|
||||
|
||||
if(!isset($result[$className])){
|
||||
throw MappingException::invalidMappingFile($className, str_replace('\\', '.', $className) . $this->_fileExtension);
|
||||
}
|
||||
@ -148,7 +148,7 @@ abstract class AbstractFileDriver implements Driver
|
||||
|
||||
/**
|
||||
* Gets the names of all mapped classes known to this driver.
|
||||
*
|
||||
*
|
||||
* @return array The names of all mapped classes known to this driver.
|
||||
*/
|
||||
public function getAllClassNames()
|
||||
@ -160,23 +160,23 @@ abstract class AbstractFileDriver implements Driver
|
||||
if ( ! is_dir($path)) {
|
||||
throw MappingException::fileMappingDriversRequireConfiguredDirectoryPath($path);
|
||||
}
|
||||
|
||||
|
||||
$iterator = new \RecursiveIteratorIterator(
|
||||
new \RecursiveDirectoryIterator($path),
|
||||
\RecursiveIteratorIterator::LEAVES_ONLY
|
||||
);
|
||||
|
||||
|
||||
foreach ($iterator as $file) {
|
||||
if (($fileName = $file->getBasename($this->_fileExtension)) == $file->getBasename()) {
|
||||
continue;
|
||||
}
|
||||
|
||||
|
||||
// NOTE: All files found here means classes are not transient!
|
||||
$classes[] = str_replace('.', '\\', $fileName);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return $classes;
|
||||
}
|
||||
|
||||
@ -191,7 +191,7 @@ abstract class AbstractFileDriver implements Driver
|
||||
protected function _findMappingFile($className)
|
||||
{
|
||||
$fileName = str_replace('\\', '.', $className) . $this->_fileExtension;
|
||||
|
||||
|
||||
// Check whether file exists
|
||||
foreach ((array) $this->_paths as $path) {
|
||||
if (file_exists($path . DIRECTORY_SEPARATOR . $fileName)) {
|
||||
@ -205,7 +205,7 @@ abstract class AbstractFileDriver implements Driver
|
||||
/**
|
||||
* Loads a mapping file with the given name and returns a map
|
||||
* from class/entity names to their corresponding elements.
|
||||
*
|
||||
*
|
||||
* @param string $file The mapping file to load.
|
||||
* @return array
|
||||
*/
|
||||
|
@ -99,7 +99,7 @@ class AnnotationDriver implements Driver
|
||||
|
||||
/**
|
||||
* Retrieve the current annotation reader
|
||||
*
|
||||
*
|
||||
* @return AnnotationReader
|
||||
*/
|
||||
public function getReader()
|
||||
@ -519,15 +519,15 @@ class AnnotationDriver implements Driver
|
||||
new \RecursiveDirectoryIterator($path, \FilesystemIterator::SKIP_DOTS),
|
||||
\RecursiveIteratorIterator::LEAVES_ONLY
|
||||
),
|
||||
'/^.+' . str_replace('.', '\.', $this->_fileExtension) . '$/i',
|
||||
'/^.+' . str_replace('.', '\.', $this->_fileExtension) . '$/i',
|
||||
\RecursiveRegexIterator::GET_MATCH
|
||||
);
|
||||
|
||||
|
||||
foreach ($iterator as $file) {
|
||||
$sourceFile = realpath($file[0]);
|
||||
|
||||
|
||||
require_once $sourceFile;
|
||||
|
||||
|
||||
$includedFiles[] = $sourceFile;
|
||||
}
|
||||
}
|
||||
|
@ -76,7 +76,7 @@ class DatabaseDriver implements Driver
|
||||
/**
|
||||
* Initializes a new AnnotationDriver that uses the given AnnotationReader for reading
|
||||
* docblock annotations.
|
||||
*
|
||||
*
|
||||
* @param AnnotationReader $reader The AnnotationReader to use.
|
||||
*/
|
||||
public function __construct(AbstractSchemaManager $schemaManager)
|
||||
@ -111,7 +111,7 @@ class DatabaseDriver implements Driver
|
||||
}
|
||||
|
||||
$tables = array();
|
||||
|
||||
|
||||
foreach ($this->_sm->listTableNames() as $tableName) {
|
||||
$tables[$tableName] = $this->_sm->listTableDetails($tableName);
|
||||
}
|
||||
@ -129,7 +129,7 @@ class DatabaseDriver implements Driver
|
||||
foreach ($foreignKeys AS $foreignKey) {
|
||||
$allForeignKeyColumns = array_merge($allForeignKeyColumns, $foreignKey->getLocalColumns());
|
||||
}
|
||||
|
||||
|
||||
$pkColumns = $table->getPrimaryKey()->getColumns();
|
||||
sort($pkColumns);
|
||||
sort($allForeignKeyColumns);
|
||||
@ -145,7 +145,7 @@ class DatabaseDriver implements Driver
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
@ -169,7 +169,7 @@ class DatabaseDriver implements Driver
|
||||
} catch(SchemaException $e) {
|
||||
$primaryKeyColumns = array();
|
||||
}
|
||||
|
||||
|
||||
if ($this->_sm->getDatabasePlatform()->supportsForeignKeyConstraints()) {
|
||||
$foreignKeys = $this->tables[$tableName]->getForeignKeys();
|
||||
} else {
|
||||
|
@ -34,18 +34,18 @@ interface Driver
|
||||
{
|
||||
/**
|
||||
* Loads the metadata for the specified class into the provided container.
|
||||
*
|
||||
*
|
||||
* @param string $className
|
||||
* @param ClassMetadataInfo $metadata
|
||||
*/
|
||||
function loadMetadataForClass($className, ClassMetadataInfo $metadata);
|
||||
|
||||
|
||||
/**
|
||||
* Gets the names of all mapped classes known to this driver.
|
||||
*
|
||||
*
|
||||
* @return array The names of all mapped classes known to this driver.
|
||||
*/
|
||||
function getAllClassNames();
|
||||
function getAllClassNames();
|
||||
|
||||
/**
|
||||
* Whether the class with the specified name should have its metadata loaded.
|
||||
|
@ -94,7 +94,7 @@ class DriverChain implements Driver
|
||||
if (!isset($driverClasses[$oid])) {
|
||||
$driverClasses[$oid] = $driver->getAllClassNames();
|
||||
}
|
||||
|
||||
|
||||
foreach ($driverClasses[$oid] AS $className) {
|
||||
if (strpos($className, $namespace) === 0) {
|
||||
$classNames[$className] = true;
|
||||
|
@ -38,21 +38,21 @@ class StaticPHPDriver implements Driver
|
||||
{
|
||||
/**
|
||||
* Paths of entity directories.
|
||||
*
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
private $_paths = array();
|
||||
|
||||
|
||||
/**
|
||||
* Map of all class names.
|
||||
*
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
private $_classNames;
|
||||
|
||||
|
||||
/**
|
||||
* The file extension of mapping documents.
|
||||
*
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
private $_fileExtension = '.php';
|
||||
|
@ -232,7 +232,7 @@ class XmlDriver extends AbstractFileDriver
|
||||
if (isset($idElement['column'])) {
|
||||
$mapping['columnName'] = (string)$idElement['column'];
|
||||
}
|
||||
|
||||
|
||||
if (isset($idElement['column-definition'])) {
|
||||
$mapping['columnDefinition'] = (string)$idElement['column-definition'];
|
||||
}
|
||||
|
@ -181,7 +181,7 @@ class YamlDriver extends AbstractFileDriver
|
||||
if (isset($idElement['length'])) {
|
||||
$mapping['length'] = $idElement['length'];
|
||||
}
|
||||
|
||||
|
||||
if (isset($idElement['columnDefinition'])) {
|
||||
$mapping['columnDefinition'] = $idElement['columnDefinition'];
|
||||
}
|
||||
|
@ -67,7 +67,7 @@ class MappingException extends \Doctrine\ORM\ORMException
|
||||
{
|
||||
return new self("No mapping file found named '$fileName' for class '$entityName'.");
|
||||
}
|
||||
|
||||
|
||||
public static function invalidMappingFile($entityName, $fileName)
|
||||
{
|
||||
return new self("Invalid mapping file '$fileName' for class '$entityName'.");
|
||||
|
@ -21,7 +21,7 @@ namespace Doctrine\ORM;
|
||||
|
||||
/**
|
||||
* Exception thrown when an ORM query unexpectedly does not return any results.
|
||||
*
|
||||
*
|
||||
* @author robo
|
||||
* @since 2.0
|
||||
*/
|
||||
|
@ -21,7 +21,7 @@ namespace Doctrine\ORM;
|
||||
|
||||
/**
|
||||
* Exception thrown when an ORM query unexpectedly returns more than one result.
|
||||
*
|
||||
*
|
||||
* @author robo
|
||||
* @since 2.0
|
||||
*/
|
||||
|
@ -144,7 +144,7 @@ class ORMException extends Exception
|
||||
return new self("Invalid repository class '".$className."'. ".
|
||||
"it must be a Doctrine\ORM\EntityRepository.");
|
||||
}
|
||||
|
||||
|
||||
public static function missingIdentifierField($className, $fieldName)
|
||||
{
|
||||
return new self("The identifier $fieldName is missing for a query of " . $className);
|
||||
|
@ -65,11 +65,11 @@ abstract class AbstractCollectionPersister
|
||||
public function delete(PersistentCollection $coll)
|
||||
{
|
||||
$mapping = $coll->getMapping();
|
||||
|
||||
|
||||
if ( ! $mapping['isOwningSide']) {
|
||||
return; // ignore inverse side
|
||||
}
|
||||
|
||||
|
||||
$sql = $this->_getDeleteSQL($coll);
|
||||
$this->_conn->executeUpdate($sql, $this->_getDeleteSQLParameters($coll));
|
||||
}
|
||||
@ -98,34 +98,34 @@ abstract class AbstractCollectionPersister
|
||||
public function update(PersistentCollection $coll)
|
||||
{
|
||||
$mapping = $coll->getMapping();
|
||||
|
||||
|
||||
if ( ! $mapping['isOwningSide']) {
|
||||
return; // ignore inverse side
|
||||
}
|
||||
|
||||
|
||||
$this->deleteRows($coll);
|
||||
//$this->updateRows($coll);
|
||||
$this->insertRows($coll);
|
||||
}
|
||||
|
||||
|
||||
public function deleteRows(PersistentCollection $coll)
|
||||
{
|
||||
{
|
||||
$deleteDiff = $coll->getDeleteDiff();
|
||||
$sql = $this->_getDeleteRowSQL($coll);
|
||||
|
||||
|
||||
foreach ($deleteDiff as $element) {
|
||||
$this->_conn->executeUpdate($sql, $this->_getDeleteRowSQLParameters($coll, $element));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//public function updateRows(PersistentCollection $coll)
|
||||
//{}
|
||||
|
||||
|
||||
public function insertRows(PersistentCollection $coll)
|
||||
{
|
||||
$insertDiff = $coll->getInsertDiff();
|
||||
$sql = $this->_getInsertRowSQL($coll);
|
||||
|
||||
|
||||
foreach ($insertDiff as $element) {
|
||||
$this->_conn->executeUpdate($sql, $this->_getInsertRowSQLParameters($coll, $element));
|
||||
}
|
||||
@ -168,7 +168,7 @@ abstract class AbstractCollectionPersister
|
||||
|
||||
/**
|
||||
* Gets the SQL statement used for deleting a row from the collection.
|
||||
*
|
||||
*
|
||||
* @param PersistentCollection $coll
|
||||
*/
|
||||
abstract protected function _getDeleteRowSQL(PersistentCollection $coll);
|
||||
|
@ -26,7 +26,7 @@ use Doctrine\ORM\Mapping\ClassMetadata,
|
||||
* Base class for entity persisters that implement a certain inheritance mapping strategy.
|
||||
* All these persisters are assumed to use a discriminator column to discriminate entity
|
||||
* types in the hierarchy.
|
||||
*
|
||||
*
|
||||
* @author Roman Borschel <roman@code-factory.org>
|
||||
* @author Benjamin Eberlei <kontakt@beberlei.de>
|
||||
* @since 2.0
|
||||
@ -39,18 +39,18 @@ abstract class AbstractEntityInheritancePersister extends BasicEntityPersister
|
||||
protected function _prepareInsertData($entity)
|
||||
{
|
||||
$data = parent::_prepareInsertData($entity);
|
||||
|
||||
|
||||
// Populate the discriminator column
|
||||
$discColumn = $this->_class->discriminatorColumn;
|
||||
$this->_columnTypes[$discColumn['name']] = $discColumn['type'];
|
||||
$data[$this->_getDiscriminatorColumnTableName()][$discColumn['name']] = $this->_class->discriminatorValue;
|
||||
|
||||
|
||||
return $data;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the name of the table that contains the discriminator column.
|
||||
*
|
||||
*
|
||||
* @return string The table name.
|
||||
*/
|
||||
abstract protected function _getDiscriminatorColumnTableName();
|
||||
@ -77,7 +77,7 @@ abstract class AbstractEntityInheritancePersister extends BasicEntityPersister
|
||||
{
|
||||
$columnAlias = $this->getSQLColumnAlias($joinColumnName);
|
||||
$this->_rsm->addMetaResult('r', $columnAlias, $joinColumnName);
|
||||
|
||||
|
||||
return $tableAlias . '.' . $joinColumnName . ' AS ' . $columnAlias;
|
||||
}
|
||||
}
|
||||
|
@ -341,7 +341,7 @@ class BasicEntityPersister
|
||||
foreach ($updateData as $columnName => $value) {
|
||||
$column = $columnName;
|
||||
$placeholder = '?';
|
||||
|
||||
|
||||
if (isset($this->_class->fieldNames[$columnName])) {
|
||||
$column = $this->_class->getQuotedColumnName($this->_class->fieldNames[$columnName], $this->_platform);
|
||||
|
||||
@ -1307,7 +1307,7 @@ class BasicEntityPersister
|
||||
|
||||
foreach ($criteria as $field => $value) {
|
||||
$conditionSql .= $conditionSql ? ' AND ' : '';
|
||||
|
||||
|
||||
$placeholder = '?';
|
||||
|
||||
if (isset($this->_class->columnNames[$field])) {
|
||||
|
@ -44,8 +44,8 @@ class ManyToManyPersister extends AbstractCollectionPersister
|
||||
{
|
||||
$mapping = $coll->getMapping();
|
||||
$class = $this->_em->getClassMetadata(get_class($coll->getOwner()));
|
||||
|
||||
return 'DELETE FROM ' . $class->getQuotedJoinTableName($mapping, $this->_conn->getDatabasePlatform())
|
||||
|
||||
return 'DELETE FROM ' . $class->getQuotedJoinTableName($mapping, $this->_conn->getDatabasePlatform())
|
||||
. ' WHERE ' . implode(' = ? AND ', $mapping['joinTableColumns']) . ' = ?';
|
||||
}
|
||||
|
||||
@ -81,9 +81,9 @@ class ManyToManyPersister extends AbstractCollectionPersister
|
||||
$mapping = $coll->getMapping();
|
||||
$columns = $mapping['joinTableColumns'];
|
||||
$class = $this->_em->getClassMetadata(get_class($coll->getOwner()));
|
||||
|
||||
|
||||
$joinTable = $class->getQuotedJoinTableName($mapping, $this->_conn->getDatabasePlatform());
|
||||
|
||||
|
||||
return 'INSERT INTO ' . $joinTable . ' (' . implode(', ', $columns) . ')'
|
||||
. ' VALUES (' . implode(', ', array_fill(0, count($columns), '?')) . ')';
|
||||
}
|
||||
@ -124,19 +124,19 @@ class ManyToManyPersister extends AbstractCollectionPersister
|
||||
|
||||
foreach ($mapping['joinTableColumns'] as $joinTableColumn) {
|
||||
$isRelationToSource = isset($mapping['relationToSourceKeyColumns'][$joinTableColumn]);
|
||||
|
||||
|
||||
if ( ! $isComposite) {
|
||||
$params[] = $isRelationToSource ? array_pop($identifier1) : array_pop($identifier2);
|
||||
|
||||
|
||||
continue;
|
||||
}
|
||||
|
||||
|
||||
if ($isRelationToSource) {
|
||||
$params[] = $identifier1[$class1->getFieldForColumn($mapping['relationToSourceKeyColumns'][$joinTableColumn])];
|
||||
|
||||
|
||||
continue;
|
||||
}
|
||||
|
||||
|
||||
$params[] = $identifier2[$class2->getFieldForColumn($mapping['relationToTargetKeyColumns'][$joinTableColumn])];
|
||||
}
|
||||
|
||||
@ -152,8 +152,8 @@ class ManyToManyPersister extends AbstractCollectionPersister
|
||||
{
|
||||
$class = $this->_em->getClassMetadata(get_class($coll->getOwner()));
|
||||
$mapping = $coll->getMapping();
|
||||
|
||||
return 'DELETE FROM ' . $class->getQuotedJoinTableName($mapping, $this->_conn->getDatabasePlatform())
|
||||
|
||||
return 'DELETE FROM ' . $class->getQuotedJoinTableName($mapping, $this->_conn->getDatabasePlatform())
|
||||
. ' WHERE ' . implode(' = ? AND ', array_keys($mapping['relationToSourceKeyColumns'])) . ' = ?';
|
||||
}
|
||||
|
||||
@ -169,21 +169,21 @@ class ManyToManyPersister extends AbstractCollectionPersister
|
||||
$identifier = $this->_uow->getEntityIdentifier($coll->getOwner());
|
||||
$mapping = $coll->getMapping();
|
||||
$params = array();
|
||||
|
||||
|
||||
// Optimization for single column identifier
|
||||
if (count($mapping['relationToSourceKeyColumns']) === 1) {
|
||||
$params[] = array_pop($identifier);
|
||||
|
||||
|
||||
return $params;
|
||||
}
|
||||
|
||||
|
||||
// Composite identifier
|
||||
$sourceClass = $this->_em->getClassMetadata(get_class($mapping->getOwner()));
|
||||
|
||||
|
||||
foreach ($mapping['relationToSourceKeyColumns'] as $relColumn => $srcColumn) {
|
||||
$params[] = $identifier[$sourceClass->fieldNames[$srcColumn]];
|
||||
}
|
||||
|
||||
|
||||
return $params;
|
||||
}
|
||||
|
||||
@ -205,12 +205,12 @@ class ManyToManyPersister extends AbstractCollectionPersister
|
||||
|
||||
$whereClauses = array();
|
||||
$params = array();
|
||||
|
||||
|
||||
foreach ($mapping['joinTableColumns'] as $joinTableColumn) {
|
||||
if ( ! isset($joinColumns[$joinTableColumn])) {
|
||||
continue;
|
||||
}
|
||||
|
||||
|
||||
$whereClauses[] = $joinTableColumn . ' = ?';
|
||||
|
||||
$params[] = ($class->containsForeignIdentifier)
|
||||
@ -240,7 +240,7 @@ class ManyToManyPersister extends AbstractCollectionPersister
|
||||
public function slice(PersistentCollection $coll, $offset, $length = null)
|
||||
{
|
||||
$mapping = $coll->getMapping();
|
||||
|
||||
|
||||
return $this->_em->getUnitOfWork()->getEntityPersister($mapping['targetEntity'])->getManyToManyCollection($mapping, $coll->getOwner(), $offset, $length);
|
||||
}
|
||||
|
||||
@ -259,12 +259,12 @@ class ManyToManyPersister extends AbstractCollectionPersister
|
||||
}
|
||||
|
||||
list($quotedJoinTable, $whereClauses, $params) = $this->getJoinTableRestrictions($coll, $element, true);
|
||||
|
||||
|
||||
$sql = 'SELECT 1 FROM ' . $quotedJoinTable . ' WHERE ' . implode(' AND ', $whereClauses);
|
||||
|
||||
return (bool) $this->_conn->fetchColumn($sql, $params);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param PersistentCollection $coll
|
||||
* @param object $element
|
||||
@ -282,10 +282,10 @@ class ManyToManyPersister extends AbstractCollectionPersister
|
||||
list($quotedJoinTable, $whereClauses, $params) = $this->getJoinTableRestrictions($coll, $element, false);
|
||||
|
||||
$sql = 'DELETE FROM ' . $quotedJoinTable . ' WHERE ' . implode(' AND ', $whereClauses);
|
||||
|
||||
|
||||
return (bool) $this->_conn->executeUpdate($sql, $params);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param \Doctrine\ORM\PersistentCollection $coll
|
||||
* @param object $element
|
||||
@ -296,13 +296,13 @@ class ManyToManyPersister extends AbstractCollectionPersister
|
||||
{
|
||||
$uow = $this->_em->getUnitOfWork();
|
||||
$mapping = $coll->getMapping();
|
||||
|
||||
|
||||
if ( ! $mapping['isOwningSide']) {
|
||||
$sourceClass = $this->_em->getClassMetadata($mapping['targetEntity']);
|
||||
$targetClass = $this->_em->getClassMetadata($mapping['sourceEntity']);
|
||||
$sourceId = $uow->getEntityIdentifier($element);
|
||||
$targetId = $uow->getEntityIdentifier($coll->getOwner());
|
||||
|
||||
|
||||
$mapping = $sourceClass->associationMappings[$mapping['mappedBy']];
|
||||
} else {
|
||||
$sourceClass = $this->_em->getClassMetadata($mapping['sourceEntity']);
|
||||
@ -310,11 +310,11 @@ class ManyToManyPersister extends AbstractCollectionPersister
|
||||
$sourceId = $uow->getEntityIdentifier($coll->getOwner());
|
||||
$targetId = $uow->getEntityIdentifier($element);
|
||||
}
|
||||
|
||||
|
||||
$quotedJoinTable = $sourceClass->getQuotedJoinTableName($mapping, $this->_conn->getDatabasePlatform());
|
||||
$whereClauses = array();
|
||||
$params = array();
|
||||
|
||||
|
||||
foreach ($mapping['joinTableColumns'] as $joinTableColumn) {
|
||||
$whereClauses[] = $joinTableColumn . ' = ?';
|
||||
|
||||
@ -324,7 +324,7 @@ class ManyToManyPersister extends AbstractCollectionPersister
|
||||
: $targetId[$targetClass->fieldNames[$mapping['relationToTargetKeyColumns'][$joinTableColumn]]];
|
||||
continue;
|
||||
}
|
||||
|
||||
|
||||
// relationToSourceKeyColumns
|
||||
$params[] = ($sourceClass->containsForeignIdentifier)
|
||||
? $sourceId[$sourceClass->getFieldForColumn($mapping['relationToSourceKeyColumns'][$joinTableColumn])]
|
||||
@ -338,7 +338,7 @@ class ManyToManyPersister extends AbstractCollectionPersister
|
||||
$whereClauses[] = $filterSql;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return array($quotedJoinTable, $whereClauses, $params);
|
||||
}
|
||||
|
||||
|
@ -44,14 +44,14 @@ class OneToManyPersister extends AbstractCollectionPersister
|
||||
{
|
||||
$mapping = $coll->getMapping();
|
||||
$class = $this->_em->getClassMetadata($mapping['targetEntity']);
|
||||
|
||||
|
||||
return 'DELETE FROM ' . $class->getQuotedTableName($this->_conn->getDatabasePlatform())
|
||||
. ' WHERE ' . implode('= ? AND ', $class->getIdentifierColumnNames()) . ' = ?';
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*
|
||||
*
|
||||
*/
|
||||
protected function _getDeleteRowSQLParameters(PersistentCollection $coll, $element)
|
||||
{
|
||||
@ -110,10 +110,10 @@ class OneToManyPersister extends AbstractCollectionPersister
|
||||
|
||||
$whereClauses = array();
|
||||
$params = array();
|
||||
|
||||
|
||||
foreach ($targetClass->associationMappings[$mapping['mappedBy']]['joinColumns'] AS $joinColumn) {
|
||||
$whereClauses[] = $joinColumn['name'] . ' = ?';
|
||||
|
||||
|
||||
$params[] = ($targetClass->containsForeignIdentifier)
|
||||
? $id[$sourceClass->getFieldForColumn($joinColumn['referencedColumnName'])]
|
||||
: $id[$sourceClass->fieldNames[$joinColumn['referencedColumnName']]];
|
||||
@ -143,7 +143,7 @@ class OneToManyPersister extends AbstractCollectionPersister
|
||||
$mapping = $coll->getMapping();
|
||||
$uow = $this->_em->getUnitOfWork();
|
||||
$persister = $uow->getEntityPersister($mapping['targetEntity']);
|
||||
|
||||
|
||||
return $persister->getOneToManyCollection($mapping, $coll->getOwner(), $offset, $length);
|
||||
}
|
||||
|
||||
@ -156,22 +156,22 @@ class OneToManyPersister extends AbstractCollectionPersister
|
||||
{
|
||||
$mapping = $coll->getMapping();
|
||||
$uow = $this->_em->getUnitOfWork();
|
||||
|
||||
|
||||
// shortcut for new entities
|
||||
if ($uow->getEntityState($element, UnitOfWork::STATE_NEW) == UnitOfWork::STATE_NEW) {
|
||||
return false;
|
||||
}
|
||||
|
||||
$persister = $uow->getEntityPersister($mapping['targetEntity']);
|
||||
|
||||
// only works with single id identifier entities. Will throw an
|
||||
// exception in Entity Persisters if that is not the case for the
|
||||
|
||||
// only works with single id identifier entities. Will throw an
|
||||
// exception in Entity Persisters if that is not the case for the
|
||||
// 'mappedBy' field.
|
||||
$id = current( $uow->getEntityIdentifier($coll->getOwner()) );
|
||||
|
||||
return $persister->exists($element, array($mapping['mappedBy'] => $id));
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param PersistentCollection $coll
|
||||
* @param object $element
|
||||
@ -190,7 +190,7 @@ class OneToManyPersister extends AbstractCollectionPersister
|
||||
$class = $this->_em->getClassMetadata($mapping['targetEntity']);
|
||||
$sql = 'DELETE FROM ' . $class->getQuotedTableName($this->_conn->getDatabasePlatform())
|
||||
. ' WHERE ' . implode('= ? AND ', $class->getIdentifierColumnNames()) . ' = ?';
|
||||
|
||||
|
||||
return (bool) $this->_conn->executeUpdate($sql, $this->_getDeleteRowSQLParameters($coll, $element));
|
||||
}
|
||||
}
|
||||
|
@ -51,33 +51,33 @@ class SingleTablePersister extends AbstractEntityInheritancePersister
|
||||
// Append discriminator column
|
||||
$discrColumn = $this->_class->discriminatorColumn['name'];
|
||||
$columnList .= ', ' . $discrColumn;
|
||||
|
||||
|
||||
$rootClass = $this->_em->getClassMetadata($this->_class->rootEntityName);
|
||||
$tableAlias = $this->_getSQLTableAlias($rootClass->name);
|
||||
$resultColumnName = $this->_platform->getSQLResultCasing($discrColumn);
|
||||
|
||||
|
||||
$this->_rsm->setDiscriminatorColumn('r', $resultColumnName);
|
||||
$this->_rsm->addMetaResult('r', $resultColumnName, $discrColumn);
|
||||
|
||||
// Append subclass columns
|
||||
foreach ($this->_class->subClasses as $subClassName) {
|
||||
$subClass = $this->_em->getClassMetadata($subClassName);
|
||||
|
||||
|
||||
// Regular columns
|
||||
foreach ($subClass->fieldMappings as $fieldName => $mapping) {
|
||||
if ( ! isset($mapping['inherited'])) {
|
||||
$columnList .= ', ' . $this->_getSelectColumnSQL($fieldName, $subClass);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Foreign key columns
|
||||
foreach ($subClass->associationMappings as $assoc) {
|
||||
if ($assoc['isOwningSide'] && $assoc['type'] & ClassMetadata::TO_ONE && ! isset($assoc['inherited'])) {
|
||||
foreach ($assoc['targetToSourceKeyColumns'] as $srcColumn) {
|
||||
if ($columnList != '') $columnList .= ', ';
|
||||
|
||||
|
||||
$columnList .= $this->getSelectJoinColumnSQL(
|
||||
$tableAlias,
|
||||
$tableAlias,
|
||||
$srcColumn,
|
||||
isset($assoc['inherited']) ? $assoc['inherited'] : $this->_class->name
|
||||
);
|
||||
@ -94,7 +94,7 @@ class SingleTablePersister extends AbstractEntityInheritancePersister
|
||||
protected function _getInsertColumnList()
|
||||
{
|
||||
$columns = parent::_getInsertColumnList();
|
||||
|
||||
|
||||
// Add discriminator column to the INSERT SQL
|
||||
$columns[] = $this->_class->discriminatorColumn['name'];
|
||||
|
||||
@ -114,19 +114,19 @@ class SingleTablePersister extends AbstractEntityInheritancePersister
|
||||
|
||||
// Append discriminator condition
|
||||
if ($conditionSql) $conditionSql .= ' AND ';
|
||||
|
||||
|
||||
$values = array();
|
||||
|
||||
|
||||
if ($this->_class->discriminatorValue !== null) { // discriminators can be 0
|
||||
$values[] = $this->_conn->quote($this->_class->discriminatorValue);
|
||||
}
|
||||
|
||||
$discrValues = array_flip($this->_class->discriminatorMap);
|
||||
|
||||
|
||||
foreach ($this->_class->subClasses as $subclassName) {
|
||||
$values[] = $this->_conn->quote($discrValues[$subclassName]);
|
||||
}
|
||||
|
||||
|
||||
$conditionSql .= $this->_getSQLTableAlias($this->_class->name) . '.' . $this->_class->discriminatorColumn['name']
|
||||
. ' IN (' . implode(', ', $values) . ')';
|
||||
|
||||
|
@ -4,5 +4,5 @@ namespace Doctrine\ORM\Persisters;
|
||||
|
||||
class UnionSubclassPersister extends BasicEntityPersister
|
||||
{
|
||||
|
||||
|
||||
}
|
@ -23,7 +23,7 @@ namespace Doctrine\ORM\Proxy;
|
||||
|
||||
/**
|
||||
* Interface for proxy classes.
|
||||
*
|
||||
*
|
||||
* @author Roman Borschel <roman@code-factory.org>
|
||||
* @since 2.0
|
||||
*/
|
||||
|
@ -640,7 +640,7 @@ final class Query extends AbstractQuery
|
||||
public function __clone()
|
||||
{
|
||||
parent::__clone();
|
||||
|
||||
|
||||
$this->_state = self::STATE_DIRTY;
|
||||
}
|
||||
}
|
||||
|
@ -38,7 +38,7 @@ class ArithmeticFactor extends Node
|
||||
* @var ArithmeticPrimary
|
||||
*/
|
||||
public $arithmeticPrimary;
|
||||
|
||||
|
||||
/**
|
||||
* @var null|boolean NULL represents no sign, TRUE means positive and FALSE means negative sign
|
||||
*/
|
||||
|
@ -33,13 +33,13 @@ namespace Doctrine\ORM\Query\AST;
|
||||
class CoalesceExpression extends Node
|
||||
{
|
||||
public $scalarExpressions = array();
|
||||
|
||||
|
||||
|
||||
public function __construct(array $scalarExpressions)
|
||||
{
|
||||
$this->scalarExpressions = $scalarExpressions;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public function dispatch($sqlWalker)
|
||||
{
|
||||
return $sqlWalker->walkCoalesceExpression($this);
|
||||
|
@ -18,7 +18,7 @@
|
||||
* and is licensed under the LGPL. For more information, see
|
||||
* <http://www.doctrine-project.org>.
|
||||
*/
|
||||
|
||||
|
||||
namespace Doctrine\ORM\Query\AST;
|
||||
|
||||
/**
|
||||
|
@ -41,7 +41,7 @@ class DeleteStatement extends Node
|
||||
{
|
||||
$this->deleteClause = $deleteClause;
|
||||
}
|
||||
|
||||
|
||||
public function dispatch($sqlWalker)
|
||||
{
|
||||
return $sqlWalker->walkDeleteStatement($this);
|
||||
|
@ -18,7 +18,7 @@
|
||||
* and is licensed under the LGPL. For more information, see
|
||||
* <http://www.doctrine-project.org>.
|
||||
*/
|
||||
|
||||
|
||||
namespace Doctrine\ORM\Query\AST;
|
||||
|
||||
/**
|
||||
|
@ -36,8 +36,8 @@ class FromClause extends Node
|
||||
public function __construct(array $identificationVariableDeclarations)
|
||||
{
|
||||
$this->identificationVariableDeclarations = $identificationVariableDeclarations;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public function dispatch($sqlWalker)
|
||||
{
|
||||
return $sqlWalker->walkFromClause($this);
|
||||
|
@ -53,9 +53,9 @@ class AbsFunction extends FunctionNode
|
||||
{
|
||||
$parser->match(Lexer::T_IDENTIFIER);
|
||||
$parser->match(Lexer::T_OPEN_PARENTHESIS);
|
||||
|
||||
|
||||
$this->simpleArithmeticExpression = $parser->SimpleArithmeticExpression();
|
||||
|
||||
|
||||
$parser->match(Lexer::T_CLOSE_PARENTHESIS);
|
||||
}
|
||||
}
|
||||
|
@ -16,7 +16,7 @@
|
||||
* and is licensed under the LGPL. For more information, see
|
||||
* <http://www.doctrine-project.org>.
|
||||
*/
|
||||
|
||||
|
||||
namespace Doctrine\ORM\Query\AST\Functions;
|
||||
|
||||
use Doctrine\ORM\Query\Lexer;
|
||||
|
@ -42,13 +42,13 @@ class IdentityFunction extends FunctionNode
|
||||
$platform = $sqlWalker->getConnection()->getDatabasePlatform();
|
||||
$dqlAlias = $this->pathExpression->identificationVariable;
|
||||
$assocField = $this->pathExpression->field;
|
||||
|
||||
|
||||
$qComp = $sqlWalker->getQueryComponent($dqlAlias);
|
||||
$class = $qComp['metadata'];
|
||||
$assoc = $class->associationMappings[$assocField];
|
||||
|
||||
|
||||
$tableAlias = $sqlWalker->getSQLTableAlias($class->getTableName(), $dqlAlias);
|
||||
|
||||
|
||||
return $tableAlias . '.' . reset($assoc['targetToSourceKeyColumns']);;
|
||||
}
|
||||
|
||||
@ -59,9 +59,9 @@ class IdentityFunction extends FunctionNode
|
||||
{
|
||||
$parser->match(Lexer::T_IDENTIFIER);
|
||||
$parser->match(Lexer::T_OPEN_PARENTHESIS);
|
||||
|
||||
|
||||
$this->pathExpression = $parser->SingleValuedAssociationPathExpression();
|
||||
|
||||
|
||||
$parser->match(Lexer::T_CLOSE_PARENTHESIS);
|
||||
}
|
||||
}
|
||||
|
@ -53,9 +53,9 @@ class LengthFunction extends FunctionNode
|
||||
{
|
||||
$parser->match(Lexer::T_IDENTIFIER);
|
||||
$parser->match(Lexer::T_OPEN_PARENTHESIS);
|
||||
|
||||
|
||||
$this->stringPrimary = $parser->StringPrimary();
|
||||
|
||||
|
||||
$parser->match(Lexer::T_CLOSE_PARENTHESIS);
|
||||
}
|
||||
}
|
||||
|
@ -61,20 +61,20 @@ class LocateFunction extends FunctionNode
|
||||
{
|
||||
$parser->match(Lexer::T_IDENTIFIER);
|
||||
$parser->match(Lexer::T_OPEN_PARENTHESIS);
|
||||
|
||||
|
||||
$this->firstStringPrimary = $parser->StringPrimary();
|
||||
|
||||
|
||||
$parser->match(Lexer::T_COMMA);
|
||||
|
||||
|
||||
$this->secondStringPrimary = $parser->StringPrimary();
|
||||
|
||||
|
||||
$lexer = $parser->getLexer();
|
||||
if ($lexer->isNextToken(Lexer::T_COMMA)) {
|
||||
$parser->match(Lexer::T_COMMA);
|
||||
|
||||
|
||||
$this->simpleArithmeticExpression = $parser->SimpleArithmeticExpression();
|
||||
}
|
||||
|
||||
|
||||
$parser->match(Lexer::T_CLOSE_PARENTHESIS);
|
||||
}
|
||||
}
|
||||
|
@ -53,9 +53,9 @@ class LowerFunction extends FunctionNode
|
||||
{
|
||||
$parser->match(Lexer::T_IDENTIFIER);
|
||||
$parser->match(Lexer::T_OPEN_PARENTHESIS);
|
||||
|
||||
|
||||
$this->stringPrimary = $parser->StringPrimary();
|
||||
|
||||
|
||||
$parser->match(Lexer::T_CLOSE_PARENTHESIS);
|
||||
}
|
||||
}
|
||||
|
@ -55,13 +55,13 @@ class ModFunction extends FunctionNode
|
||||
{
|
||||
$parser->match(Lexer::T_MOD);
|
||||
$parser->match(Lexer::T_OPEN_PARENTHESIS);
|
||||
|
||||
|
||||
$this->firstSimpleArithmeticExpression = $parser->SimpleArithmeticExpression();
|
||||
|
||||
|
||||
$parser->match(Lexer::T_COMMA);
|
||||
|
||||
|
||||
$this->secondSimpleArithmeticExpression = $parser->SimpleArithmeticExpression();
|
||||
|
||||
|
||||
$parser->match(Lexer::T_CLOSE_PARENTHESIS);
|
||||
}
|
||||
}
|
||||
|
@ -45,7 +45,7 @@ class SizeFunction extends FunctionNode
|
||||
$platform = $sqlWalker->getConnection()->getDatabasePlatform();
|
||||
$dqlAlias = $this->collectionPathExpression->identificationVariable;
|
||||
$assocField = $this->collectionPathExpression->field;
|
||||
|
||||
|
||||
$qComp = $sqlWalker->getQueryComponent($dqlAlias);
|
||||
$class = $qComp['metadata'];
|
||||
$assoc = $class->associationMappings[$assocField];
|
||||
@ -61,7 +61,7 @@ class SizeFunction extends FunctionNode
|
||||
$owningAssoc = $targetClass->associationMappings[$assoc['mappedBy']];
|
||||
|
||||
$first = true;
|
||||
|
||||
|
||||
foreach ($owningAssoc['targetToSourceKeyColumns'] as $targetColumn => $sourceColumn) {
|
||||
if ($first) $first = false; else $sql .= ' AND ';
|
||||
|
||||
@ -100,7 +100,7 @@ class SizeFunction extends FunctionNode
|
||||
. $sourceTableAlias . '.' . $sourceColumnName;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return '(' . $sql . ')';
|
||||
}
|
||||
|
||||
@ -110,12 +110,12 @@ class SizeFunction extends FunctionNode
|
||||
public function parse(\Doctrine\ORM\Query\Parser $parser)
|
||||
{
|
||||
$lexer = $parser->getLexer();
|
||||
|
||||
|
||||
$parser->match(Lexer::T_SIZE);
|
||||
$parser->match(Lexer::T_OPEN_PARENTHESIS);
|
||||
|
||||
|
||||
$this->collectionPathExpression = $parser->CollectionValuedPathExpression();
|
||||
|
||||
|
||||
$parser->match(Lexer::T_CLOSE_PARENTHESIS);
|
||||
}
|
||||
}
|
||||
|
@ -52,9 +52,9 @@ class SqrtFunction extends FunctionNode
|
||||
{
|
||||
$parser->match(Lexer::T_IDENTIFIER);
|
||||
$parser->match(Lexer::T_OPEN_PARENTHESIS);
|
||||
|
||||
|
||||
$this->simpleArithmeticExpression = $parser->SimpleArithmeticExpression();
|
||||
|
||||
|
||||
$parser->match(Lexer::T_CLOSE_PARENTHESIS);
|
||||
}
|
||||
}
|
||||
|
@ -64,15 +64,15 @@ class SubstringFunction extends FunctionNode
|
||||
$parser->match(Lexer::T_OPEN_PARENTHESIS);
|
||||
|
||||
$this->stringPrimary = $parser->StringPrimary();
|
||||
|
||||
|
||||
$parser->match(Lexer::T_COMMA);
|
||||
|
||||
|
||||
$this->firstSimpleArithmeticExpression = $parser->SimpleArithmeticExpression();
|
||||
|
||||
$lexer = $parser->getLexer();
|
||||
if ($lexer->isNextToken(Lexer::T_COMMA)) {
|
||||
$parser->match(Lexer::T_COMMA);
|
||||
|
||||
|
||||
$this->secondSimpleArithmeticExpression = $parser->SimpleArithmeticExpression();
|
||||
}
|
||||
|
||||
|
@ -53,9 +53,9 @@ class UpperFunction extends FunctionNode
|
||||
{
|
||||
$parser->match(Lexer::T_IDENTIFIER);
|
||||
$parser->match(Lexer::T_OPEN_PARENTHESIS);
|
||||
|
||||
|
||||
$this->stringPrimary = $parser->StringPrimary();
|
||||
|
||||
|
||||
$parser->match(Lexer::T_CLOSE_PARENTHESIS);
|
||||
}
|
||||
}
|
||||
|
@ -20,7 +20,7 @@
|
||||
namespace Doctrine\ORM\Query\AST;
|
||||
|
||||
/**
|
||||
* GeneralCaseExpression ::= "CASE" WhenClause {WhenClause}* "ELSE" ScalarExpression "END"
|
||||
* GeneralCaseExpression ::= "CASE" WhenClause {WhenClause}* "ELSE" ScalarExpression "END"
|
||||
*
|
||||
* @since 2.2
|
||||
* @license http://www.opensource.org/licenses/lgpl-license.php LGPL
|
||||
@ -39,8 +39,8 @@ class GeneralCaseExpression extends Node
|
||||
{
|
||||
$this->whenClauses = $whenClauses;
|
||||
$this->elseScalarExpression = $elseScalarExpression;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public function dispatch($sqlWalker)
|
||||
{
|
||||
return $sqlWalker->walkGeneralCaseExpression($this);
|
||||
|
@ -44,7 +44,7 @@ class IdentificationVariableDeclaration extends Node
|
||||
$this->indexBy = $indexBy;
|
||||
$this->joinVariableDeclarations = $joinVariableDecls;
|
||||
}
|
||||
|
||||
|
||||
public function dispatch($sqlWalker)
|
||||
{
|
||||
return $sqlWalker->walkIdentificationVariableDeclaration($this);
|
||||
|
@ -39,8 +39,8 @@ class IndexBy extends Node
|
||||
public function __construct($simpleStateFieldPathExpression)
|
||||
{
|
||||
$this->simpleStateFieldPathExpression = $simpleStateFieldPathExpression;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public function dispatch($sqlWalker)
|
||||
{
|
||||
return $sqlWalker->walkIndexBy($this);
|
||||
|
@ -36,7 +36,7 @@ class InstanceOfExpression extends Node
|
||||
public $not;
|
||||
public $identificationVariable;
|
||||
public $value;
|
||||
|
||||
|
||||
public function __construct($identVariable)
|
||||
{
|
||||
$this->identificationVariable = $identVariable;
|
||||
|
@ -39,7 +39,7 @@ class Join extends Node
|
||||
const JOIN_TYPE_LEFTOUTER = 2;
|
||||
const JOIN_TYPE_INNER = 3;
|
||||
|
||||
public $joinType = self::JOIN_TYPE_INNER;
|
||||
public $joinType = self::JOIN_TYPE_INNER;
|
||||
public $joinAssociationPathExpression = null;
|
||||
public $aliasIdentificationVariable = null;
|
||||
public $conditionalExpression = null;
|
||||
@ -50,7 +50,7 @@ class Join extends Node
|
||||
$this->joinAssociationPathExpression = $joinAssocPathExpr;
|
||||
$this->aliasIdentificationVariable = $aliasIdentVar;
|
||||
}
|
||||
|
||||
|
||||
public function dispatch($sqlWalker)
|
||||
{
|
||||
return $sqlWalker->walkJoin($this);
|
||||
|
@ -18,7 +18,7 @@
|
||||
* and is licensed under the LGPL. For more information, see
|
||||
* <http://www.doctrine-project.org>.
|
||||
*/
|
||||
|
||||
|
||||
namespace Doctrine\ORM\Query\AST;
|
||||
|
||||
/**
|
||||
|
@ -42,7 +42,7 @@ class JoinVariableDeclaration extends Node
|
||||
$this->join = $join;
|
||||
$this->indexBy = $indexBy;
|
||||
}
|
||||
|
||||
|
||||
public function dispatch($sqlWalker)
|
||||
{
|
||||
return $sqlWalker->walkJoinVariableDeclaration($this);
|
||||
|
@ -7,16 +7,16 @@ class Literal extends Node
|
||||
const STRING = 1;
|
||||
const BOOLEAN = 2;
|
||||
const NUMERIC = 3;
|
||||
|
||||
|
||||
public $type;
|
||||
public $value;
|
||||
|
||||
|
||||
public function __construct($type, $value)
|
||||
{
|
||||
$this->type = $type;
|
||||
$this->value = $value;
|
||||
}
|
||||
|
||||
|
||||
public function dispatch($walker)
|
||||
{
|
||||
return $walker->walkLiteral($this);
|
||||
|
@ -36,16 +36,16 @@ abstract class Node
|
||||
{
|
||||
/**
|
||||
* Double-dispatch method, supposed to dispatch back to the walker.
|
||||
*
|
||||
*
|
||||
* Implementation is not mandatory for all nodes.
|
||||
*
|
||||
*
|
||||
* @param $walker
|
||||
*/
|
||||
public function dispatch($walker)
|
||||
{
|
||||
throw ASTException::noDispatchForNode($this);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Dumps the AST Node into a string representation for information purpose only
|
||||
*
|
||||
@ -55,36 +55,36 @@ abstract class Node
|
||||
{
|
||||
return $this->dump($this);
|
||||
}
|
||||
|
||||
|
||||
public function dump($obj)
|
||||
{
|
||||
static $ident = 0;
|
||||
|
||||
|
||||
$str = '';
|
||||
|
||||
|
||||
if ($obj instanceof Node) {
|
||||
$str .= get_class($obj) . '(' . PHP_EOL;
|
||||
$props = get_object_vars($obj);
|
||||
|
||||
|
||||
foreach ($props as $name => $prop) {
|
||||
$ident += 4;
|
||||
$str .= str_repeat(' ', $ident) . '"' . $name . '": '
|
||||
$str .= str_repeat(' ', $ident) . '"' . $name . '": '
|
||||
. $this->dump($prop) . ',' . PHP_EOL;
|
||||
$ident -= 4;
|
||||
}
|
||||
|
||||
|
||||
$str .= str_repeat(' ', $ident) . ')';
|
||||
} else if (is_array($obj)) {
|
||||
$ident += 4;
|
||||
$str .= 'array(';
|
||||
$some = false;
|
||||
|
||||
|
||||
foreach ($obj as $k => $v) {
|
||||
$str .= PHP_EOL . str_repeat(' ', $ident) . '"'
|
||||
$str .= PHP_EOL . str_repeat(' ', $ident) . '"'
|
||||
. $k . '" => ' . $this->dump($v) . ',';
|
||||
$some = true;
|
||||
}
|
||||
|
||||
|
||||
$ident -= 4;
|
||||
$str .= ($some ? PHP_EOL . str_repeat(' ', $ident) : '') . ')';
|
||||
} else if (is_object($obj)) {
|
||||
@ -92,7 +92,7 @@ abstract class Node
|
||||
} else {
|
||||
$str .= var_export($obj, true);
|
||||
}
|
||||
|
||||
|
||||
return $str;
|
||||
}
|
||||
}
|
@ -36,7 +36,7 @@ class NullComparisonExpression extends Node
|
||||
{
|
||||
public $not;
|
||||
public $expression;
|
||||
|
||||
|
||||
public function __construct($expression)
|
||||
{
|
||||
$this->expression = $expression;
|
||||
|
@ -33,15 +33,15 @@ namespace Doctrine\ORM\Query\AST;
|
||||
class NullIfExpression extends Node
|
||||
{
|
||||
public $firstExpression;
|
||||
|
||||
|
||||
public $secondExpression;
|
||||
|
||||
public function __construct($firstExpression, $secondExpression)
|
||||
{
|
||||
$this->firstExpression = $firstExpression;
|
||||
$this->secondExpression = $secondExpression;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public function dispatch($sqlWalker)
|
||||
{
|
||||
return $sqlWalker->walkNullIfExpression($this);
|
||||
|
@ -36,7 +36,7 @@ class OrderByItem extends Node
|
||||
{
|
||||
public $expression;
|
||||
public $type;
|
||||
|
||||
|
||||
public function __construct($expression)
|
||||
{
|
||||
$this->expression = $expression;
|
||||
|
@ -6,7 +6,7 @@ class PartialObjectExpression extends Node
|
||||
{
|
||||
public $identificationVariable;
|
||||
public $partialFieldSet;
|
||||
|
||||
|
||||
public function __construct($identificationVariable, array $partialFieldSet)
|
||||
{
|
||||
$this->identificationVariable = $identificationVariable;
|
||||
|
@ -16,7 +16,7 @@
|
||||
* and is licensed under the LGPL. For more information, see
|
||||
* <http://www.doctrine-project.org>.
|
||||
*/
|
||||
|
||||
|
||||
namespace Doctrine\ORM\Query\AST;
|
||||
|
||||
/**
|
||||
@ -27,7 +27,7 @@ namespace Doctrine\ORM\Query\AST;
|
||||
* CollectionValuedPathExpression ::= IdentificationVariable "." CollectionValuedAssociationField
|
||||
* StateField ::= {EmbeddedClassStateField "."}* SimpleStateField
|
||||
* SimpleStateFieldPathExpression ::= IdentificationVariable "." StateField
|
||||
*
|
||||
*
|
||||
* @since 2.0
|
||||
* @author Guilherme Blanco <guilhermeblanco@hotmail.com>
|
||||
* @author Jonathan Wage <jonwage@gmail.com>
|
||||
@ -38,19 +38,19 @@ class PathExpression extends Node
|
||||
const TYPE_COLLECTION_VALUED_ASSOCIATION = 2;
|
||||
const TYPE_SINGLE_VALUED_ASSOCIATION = 4;
|
||||
const TYPE_STATE_FIELD = 8;
|
||||
|
||||
|
||||
public $type;
|
||||
public $expectedType;
|
||||
public $identificationVariable;
|
||||
public $field;
|
||||
|
||||
|
||||
public function __construct($expectedType, $identificationVariable, $field = null)
|
||||
{
|
||||
$this->expectedType = $expectedType;
|
||||
$this->identificationVariable = $identificationVariable;
|
||||
$this->field = $field;
|
||||
}
|
||||
|
||||
|
||||
public function dispatch($walker)
|
||||
{
|
||||
return $walker->walkPathExpression($this);
|
||||
|
@ -41,8 +41,8 @@ class RangeVariableDeclaration extends Node
|
||||
{
|
||||
$this->abstractSchemaName = $abstractSchemaName;
|
||||
$this->aliasIdentificationVariable = $aliasIdentificationVar;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public function dispatch($walker)
|
||||
{
|
||||
return $walker->walkRangeVariableDeclaration($this);
|
||||
|
@ -42,7 +42,7 @@ class SelectClause extends Node
|
||||
$this->isDistinct = $isDistinct;
|
||||
$this->selectExpressions = $selectExpressions;
|
||||
}
|
||||
|
||||
|
||||
public function dispatch($sqlWalker)
|
||||
{
|
||||
return $sqlWalker->walkSelectClause($this);
|
||||
|
@ -44,8 +44,8 @@ class SelectExpression extends Node
|
||||
$this->expression = $expression;
|
||||
$this->fieldIdentificationVariable = $fieldIdentificationVariable;
|
||||
$this->hiddenAliasResultVariable = $hiddenAliasResultVariable;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public function dispatch($sqlWalker)
|
||||
{
|
||||
return $sqlWalker->walkSelectExpression($this);
|
||||
|
@ -44,8 +44,8 @@ class SelectStatement extends Node
|
||||
public function __construct($selectClause, $fromClause) {
|
||||
$this->selectClause = $selectClause;
|
||||
$this->fromClause = $fromClause;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public function dispatch($sqlWalker)
|
||||
{
|
||||
return $sqlWalker->walkSelectStatement($this);
|
||||
|
@ -20,7 +20,7 @@
|
||||
namespace Doctrine\ORM\Query\AST;
|
||||
|
||||
/**
|
||||
* SimpleCaseExpression ::= "CASE" CaseOperand SimpleWhenClause {SimpleWhenClause}* "ELSE" ScalarExpression "END"
|
||||
* SimpleCaseExpression ::= "CASE" CaseOperand SimpleWhenClause {SimpleWhenClause}* "ELSE" ScalarExpression "END"
|
||||
*
|
||||
* @since 2.2
|
||||
* @license http://www.opensource.org/licenses/lgpl-license.php LGPL
|
||||
@ -41,8 +41,8 @@ class SimpleCaseExpression extends Node
|
||||
$this->caseOperand = $caseOperand;
|
||||
$this->simpleWhenClauses = $simpleWhenClauses;
|
||||
$this->elseScalarExpression = $elseScalarExpression;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public function dispatch($sqlWalker)
|
||||
{
|
||||
return $sqlWalker->walkSimpleCaseExpression($this);
|
||||
|
@ -42,7 +42,7 @@ class SimpleSelectClause extends Node
|
||||
$this->simpleSelectExpression = $simpleSelectExpression;
|
||||
$this->isDistinct = $isDistinct;
|
||||
}
|
||||
|
||||
|
||||
public function dispatch($sqlWalker)
|
||||
{
|
||||
return $sqlWalker->walkSimpleSelectClause($this);
|
||||
|
@ -41,8 +41,8 @@ class SimpleSelectExpression extends Node
|
||||
public function __construct($expression)
|
||||
{
|
||||
$this->expression = $expression;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public function dispatch($sqlWalker)
|
||||
{
|
||||
return $sqlWalker->walkSimpleSelectExpression($this);
|
||||
|
@ -20,7 +20,7 @@
|
||||
namespace Doctrine\ORM\Query\AST;
|
||||
|
||||
/**
|
||||
* SimpleWhenClause ::= "WHEN" ScalarExpression "THEN" ScalarExpression
|
||||
* SimpleWhenClause ::= "WHEN" ScalarExpression "THEN" ScalarExpression
|
||||
*
|
||||
* @since 2.2
|
||||
* @license http://www.opensource.org/licenses/lgpl-license.php LGPL
|
||||
@ -39,8 +39,8 @@ class SimpleWhenClause extends Node
|
||||
{
|
||||
$this->caseScalarExpression = $caseScalarExpression;
|
||||
$this->thenScalarExpression = $thenScalarExpression;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public function dispatch($sqlWalker)
|
||||
{
|
||||
return $sqlWalker->walkWhenClauseExpression($this);
|
||||
|
@ -45,8 +45,8 @@ class Subselect extends Node
|
||||
{
|
||||
$this->simpleSelectClause = $simpleSelectClause;
|
||||
$this->subselectFromClause = $subselectFromClause;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public function dispatch($sqlWalker)
|
||||
{
|
||||
return $sqlWalker->walkSubselect($this);
|
||||
|
@ -39,8 +39,8 @@ class SubselectFromClause extends Node
|
||||
public function __construct(array $identificationVariableDeclarations)
|
||||
{
|
||||
$this->identificationVariableDeclarations = $identificationVariableDeclarations;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public function dispatch($sqlWalker)
|
||||
{
|
||||
return $sqlWalker->walkSubselectFromClause($this);
|
||||
|
@ -46,4 +46,4 @@ class UpdateStatement extends Node
|
||||
{
|
||||
return $sqlWalker->walkUpdateStatement($this);
|
||||
}
|
||||
}
|
||||
}
|
@ -20,7 +20,7 @@
|
||||
namespace Doctrine\ORM\Query\AST;
|
||||
|
||||
/**
|
||||
* WhenClause ::= "WHEN" ConditionalExpression "THEN" ScalarExpression
|
||||
* WhenClause ::= "WHEN" ConditionalExpression "THEN" ScalarExpression
|
||||
*
|
||||
* @since 2.2
|
||||
* @license http://www.opensource.org/licenses/lgpl-license.php LGPL
|
||||
@ -39,8 +39,8 @@ class WhenClause extends Node
|
||||
{
|
||||
$this->caseConditionExpression = $caseConditionExpression;
|
||||
$this->thenScalarExpression = $thenScalarExpression;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public function dispatch($sqlWalker)
|
||||
{
|
||||
return $sqlWalker->walkWhenClauseExpression($this);
|
||||
|
@ -36,7 +36,7 @@ class MultiTableDeleteExecutor extends AbstractSqlExecutor
|
||||
private $_createTempTableSql;
|
||||
private $_dropTempTableSql;
|
||||
private $_insertSql;
|
||||
|
||||
|
||||
/**
|
||||
* Initializes a new <tt>MultiTableDeleteExecutor</tt>.
|
||||
*
|
||||
@ -64,7 +64,7 @@ class MultiTableDeleteExecutor extends AbstractSqlExecutor
|
||||
|
||||
$this->_insertSql = 'INSERT INTO ' . $tempTable . ' (' . $idColumnList . ')'
|
||||
. ' SELECT t0.' . implode(', t0.', $idColumnNames);
|
||||
|
||||
|
||||
$rangeDecl = new AST\RangeVariableDeclaration($primaryClass->name, $primaryDqlAlias);
|
||||
$fromClause = new AST\FromClause(array(new AST\IdentificationVariableDeclaration($rangeDecl, null, array())));
|
||||
$this->_insertSql .= $sqlWalker->walkFromClause($fromClause);
|
||||
@ -84,7 +84,7 @@ class MultiTableDeleteExecutor extends AbstractSqlExecutor
|
||||
$this->_sqlStatements[] = 'DELETE FROM ' . $tableName
|
||||
. ' WHERE (' . $idColumnList . ') IN (' . $idSubselect . ')';
|
||||
}
|
||||
|
||||
|
||||
// 4. Store DDL for temporary identifier table.
|
||||
$columnDefinitions = array();
|
||||
foreach ($idColumnNames as $idColumnName) {
|
||||
|
@ -80,7 +80,7 @@ class MultiTableUpdateExecutor extends AbstractSqlExecutor
|
||||
// 3. Create and store UPDATE statements
|
||||
$classNames = array_merge($primaryClass->parentClasses, array($primaryClass->name), $primaryClass->subClasses);
|
||||
$i = -1;
|
||||
|
||||
|
||||
foreach (array_reverse($classNames) as $className) {
|
||||
$affected = false;
|
||||
$class = $em->getClassMetadata($className);
|
||||
@ -88,27 +88,27 @@ class MultiTableUpdateExecutor extends AbstractSqlExecutor
|
||||
|
||||
foreach ($updateItems as $updateItem) {
|
||||
$field = $updateItem->pathExpression->field;
|
||||
|
||||
|
||||
if (isset($class->fieldMappings[$field]) && ! isset($class->fieldMappings[$field]['inherited']) ||
|
||||
isset($class->associationMappings[$field]) && ! isset($class->associationMappings[$field]['inherited'])) {
|
||||
$newValue = $updateItem->newValue;
|
||||
|
||||
|
||||
if ( ! $affected) {
|
||||
$affected = true;
|
||||
++$i;
|
||||
} else {
|
||||
$updateSql .= ', ';
|
||||
}
|
||||
|
||||
|
||||
$updateSql .= $sqlWalker->walkUpdateItem($updateItem);
|
||||
|
||||
|
||||
//FIXME: parameters can be more deeply nested. traverse the tree.
|
||||
//FIXME (URGENT): With query cache the parameter is out of date. Move to execute() stage.
|
||||
if ($newValue instanceof AST\InputParameter) {
|
||||
$paramKey = $newValue->name;
|
||||
$this->_sqlParameters[$i]['parameters'][] = $sqlWalker->getQuery()->getParameter($paramKey);
|
||||
$this->_sqlParameters[$i]['types'][] = $sqlWalker->getQuery()->getParameterType($paramKey);
|
||||
|
||||
|
||||
++$this->_numParametersInUpdateClause;
|
||||
}
|
||||
}
|
||||
@ -118,12 +118,12 @@ class MultiTableUpdateExecutor extends AbstractSqlExecutor
|
||||
$this->_sqlStatements[$i] = $updateSql . ' WHERE (' . $idColumnList . ') IN (' . $idSubselect . ')';
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Append WHERE clause to insertSql, if there is one.
|
||||
if ($AST->whereClause) {
|
||||
$this->_insertSql .= $sqlWalker->walkWhereClause($AST->whereClause);
|
||||
}
|
||||
|
||||
|
||||
// 4. Store DDL for temporary identifier table.
|
||||
$columnDefinitions = array();
|
||||
|
||||
@ -133,10 +133,10 @@ class MultiTableUpdateExecutor extends AbstractSqlExecutor
|
||||
'type' => Type::getType($rootClass->getTypeOfColumn($idColumnName))
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
$this->_createTempTableSql = $platform->getCreateTemporaryTableSnippetSQL() . ' ' . $tempTable . ' ('
|
||||
. $platform->getColumnDeclarationListSQL($columnDefinitions) . ')';
|
||||
|
||||
|
||||
$this->_dropTempTableSql = $platform->getDropTemporaryTableSQL($tempTable);
|
||||
}
|
||||
|
||||
@ -152,8 +152,8 @@ class MultiTableUpdateExecutor extends AbstractSqlExecutor
|
||||
|
||||
// Insert identifiers. Parameters from the update clause are cut off.
|
||||
$numUpdated = $conn->executeUpdate(
|
||||
$this->_insertSql,
|
||||
array_slice($params, $this->_numParametersInUpdateClause),
|
||||
$this->_insertSql,
|
||||
array_slice($params, $this->_numParametersInUpdateClause),
|
||||
array_slice($types, $this->_numParametersInUpdateClause)
|
||||
);
|
||||
|
||||
@ -161,12 +161,12 @@ class MultiTableUpdateExecutor extends AbstractSqlExecutor
|
||||
for ($i=0, $count=count($this->_sqlStatements); $i<$count; ++$i) {
|
||||
$parameters = array();
|
||||
$types = array();
|
||||
|
||||
|
||||
if (isset($this->_sqlParameters[$i])) {
|
||||
$parameters = isset($this->_sqlParameters[$i]['parameters']) ? $this->_sqlParameters[$i]['parameters'] : array();
|
||||
$types = isset($this->_sqlParameters[$i]['types']) ? $this->_sqlParameters[$i]['types'] : array();
|
||||
}
|
||||
|
||||
|
||||
$conn->executeUpdate($this->_sqlStatements[$i], $parameters, $types);
|
||||
}
|
||||
|
||||
|
@ -30,7 +30,7 @@ use Doctrine\DBAL\Connection,
|
||||
* @author Roman Borschel <roman@code-factory.org>
|
||||
* @link www.doctrine-project.org
|
||||
* @since 2.0
|
||||
* @todo This is exactly the same as SingleSelectExecutor. Unify in SingleStatementExecutor.
|
||||
* @todo This is exactly the same as SingleSelectExecutor. Unify in SingleStatementExecutor.
|
||||
*/
|
||||
class SingleTableDeleteUpdateExecutor extends AbstractSqlExecutor
|
||||
{
|
||||
|
@ -40,7 +40,7 @@ class Comparison
|
||||
const LTE = '<=';
|
||||
const GT = '>';
|
||||
const GTE = '>=';
|
||||
|
||||
|
||||
private $_leftExpr;
|
||||
private $_operator;
|
||||
private $_rightExpr;
|
||||
|
@ -38,17 +38,17 @@ class From
|
||||
* @var string
|
||||
*/
|
||||
private $_from;
|
||||
|
||||
|
||||
/**
|
||||
* @var string
|
||||
* @var string
|
||||
*/
|
||||
private $_alias;
|
||||
|
||||
|
||||
/**
|
||||
* @var string
|
||||
* @var string
|
||||
*/
|
||||
private $_indexBy;
|
||||
|
||||
|
||||
/**
|
||||
* @param string $from The class name.
|
||||
* @param string $alias The alias of the class.
|
||||
@ -60,7 +60,7 @@ class From
|
||||
$this->_alias = $alias;
|
||||
$this->_indexBy = $indexBy;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
@ -82,7 +82,7 @@ class From
|
||||
*/
|
||||
public function __toString()
|
||||
{
|
||||
return $this->_from . ' ' . $this->_alias .
|
||||
return $this->_from . ' ' . $this->_alias .
|
||||
($this->_indexBy ? ' INDEX BY ' . $this->_indexBy : '');
|
||||
}
|
||||
}
|
@ -36,10 +36,10 @@ class Join
|
||||
{
|
||||
const INNER_JOIN = 'INNER';
|
||||
const LEFT_JOIN = 'LEFT';
|
||||
|
||||
|
||||
const ON = 'ON';
|
||||
const WITH = 'WITH';
|
||||
|
||||
|
||||
private $_joinType;
|
||||
private $_join;
|
||||
private $_alias;
|
||||
|
@ -49,18 +49,18 @@ class Math
|
||||
{
|
||||
// Adjusting Left Expression
|
||||
$leftExpr = (string) $this->_leftExpr;
|
||||
|
||||
|
||||
if ($this->_leftExpr instanceof Math) {
|
||||
$leftExpr = '(' . $leftExpr . ')';
|
||||
}
|
||||
|
||||
|
||||
// Adjusting Right Expression
|
||||
$rightExpr = (string) $this->_rightExpr;
|
||||
|
||||
|
||||
if ($this->_rightExpr instanceof Math) {
|
||||
$rightExpr = '(' . $rightExpr . ')';
|
||||
}
|
||||
|
||||
|
||||
return $leftExpr . ' ' . $this->_operator . ' ' . $rightExpr;
|
||||
}
|
||||
}
|
@ -39,9 +39,9 @@ class ParameterTypeInferer
|
||||
* Infer type of a given value, returning a compatible constant:
|
||||
* - Type (\Doctrine\DBAL\Types\Type::*)
|
||||
* - Connection (\Doctrine\DBAL\Connection::PARAM_*)
|
||||
*
|
||||
*
|
||||
* @param mixed $value Parameter value
|
||||
*
|
||||
*
|
||||
* @return mixed Parameter type constant
|
||||
*/
|
||||
public static function inferType($value)
|
||||
|
@ -37,14 +37,14 @@ class ParserResult
|
||||
{
|
||||
/**
|
||||
* The SQL executor used for executing the SQL.
|
||||
*
|
||||
*
|
||||
* @var \Doctrine\ORM\Query\Exec\AbstractSqlExecutor
|
||||
*/
|
||||
private $_sqlExecutor;
|
||||
|
||||
/**
|
||||
* The ResultSetMapping that describes how to map the SQL result set.
|
||||
*
|
||||
*
|
||||
* @var \Doctrine\ORM\Query\ResultSetMapping
|
||||
*/
|
||||
private $_resultSetMapping;
|
||||
@ -55,7 +55,7 @@ class ParserResult
|
||||
* @var array
|
||||
*/
|
||||
private $_parameterMappings = array();
|
||||
|
||||
|
||||
/**
|
||||
* Initializes a new instance of the <tt>ParserResult</tt> class.
|
||||
* The new instance is initialized with an empty <tt>ResultSetMapping</tt>.
|
||||
@ -67,7 +67,7 @@ class ParserResult
|
||||
|
||||
/**
|
||||
* Gets the ResultSetMapping for the parsed query.
|
||||
*
|
||||
*
|
||||
* @return ResultSetMapping The result set mapping of the parsed query or NULL
|
||||
* if the query is not a SELECT query.
|
||||
*/
|
||||
@ -88,7 +88,7 @@ class ParserResult
|
||||
|
||||
/**
|
||||
* Sets the SQL executor that should be used for this ParserResult.
|
||||
*
|
||||
*
|
||||
* @param \Doctrine\ORM\Query\Exec\AbstractSqlExecutor $executor
|
||||
*/
|
||||
public function setSqlExecutor($executor)
|
||||
@ -98,14 +98,14 @@ class ParserResult
|
||||
|
||||
/**
|
||||
* Gets the SQL executor used by this ParserResult.
|
||||
*
|
||||
*
|
||||
* @return \Doctrine\ORM\Query\Exec\AbstractSqlExecutor
|
||||
*/
|
||||
public function getSqlExecutor()
|
||||
{
|
||||
return $this->_sqlExecutor;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Adds a DQL to SQL parameter mapping. One DQL parameter name/position can map to
|
||||
* several SQL parameter positions.
|
||||
@ -117,17 +117,17 @@ class ParserResult
|
||||
{
|
||||
$this->_parameterMappings[$dqlPosition][] = $sqlPosition;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Gets all DQL to SQL parameter mappings.
|
||||
*
|
||||
*
|
||||
* @return array The parameter mappings.
|
||||
*/
|
||||
public function getParameterMappings()
|
||||
{
|
||||
return $this->_parameterMappings;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Gets the SQL parameter positions for a DQL parameter name/position.
|
||||
*
|
||||
|
@ -131,7 +131,7 @@ class ResultSetMapping
|
||||
if ($resultAlias !== null) {
|
||||
$this->isMixed = true;
|
||||
}
|
||||
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
@ -150,7 +150,7 @@ class ResultSetMapping
|
||||
{
|
||||
$this->discriminatorColumns[$alias] = $discrColumn;
|
||||
$this->columnOwnerMap[$discrColumn] = $alias;
|
||||
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
@ -185,7 +185,7 @@ class ResultSetMapping
|
||||
throw new \LogicException($message);
|
||||
}
|
||||
*/
|
||||
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
@ -198,7 +198,7 @@ class ResultSetMapping
|
||||
public function addIndexByScalar($resultColumnName)
|
||||
{
|
||||
$this->indexByMap['scalars'] = $resultColumnName;
|
||||
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
@ -212,7 +212,7 @@ class ResultSetMapping
|
||||
public function addIndexByColumn($alias, $resultColumnName)
|
||||
{
|
||||
$this->indexByMap[$alias] = $resultColumnName;
|
||||
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
@ -268,7 +268,7 @@ class ResultSetMapping
|
||||
if ( ! $this->isMixed && $this->scalarMappings) {
|
||||
$this->isMixed = true;
|
||||
}
|
||||
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
@ -287,7 +287,7 @@ class ResultSetMapping
|
||||
$this->aliasMap[$alias] = $class;
|
||||
$this->parentAliasMap[$alias] = $parentAlias;
|
||||
$this->relationMap[$alias] = $relation;
|
||||
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
@ -306,7 +306,7 @@ class ResultSetMapping
|
||||
if ( ! $this->isMixed && $this->fieldMappings) {
|
||||
$this->isMixed = true;
|
||||
}
|
||||
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
@ -469,7 +469,7 @@ class ResultSetMapping
|
||||
if ($isIdentifierColumn) {
|
||||
$this->isIdentifierColumn[$alias][$columnName] = true;
|
||||
}
|
||||
|
||||
|
||||
return $this;
|
||||
}
|
||||
}
|
||||
|
@ -51,11 +51,11 @@ class MetadataCommand extends Console\Command\Command
|
||||
'If defined, cache entries will be flushed instead of deleted/invalidated.'
|
||||
)
|
||||
));
|
||||
|
||||
|
||||
$fullName = $this->getName();
|
||||
$this->setHelp(<<<EOT
|
||||
The <info>$fullName</info> command is meant to clear the metadata cache of associated Entity Manager.
|
||||
It is possible to invalidate all cache entries at once - called delete -, or flushes the cache provider
|
||||
It is possible to invalidate all cache entries at once - called delete -, or flushes the cache provider
|
||||
instance completely.
|
||||
|
||||
The execution type differ on how you execute the command.
|
||||
@ -66,7 +66,7 @@ If you want to invalidate the entries (and not delete from cache instance), this
|
||||
Alternatively, if you want to flush the cache provider using this command:
|
||||
|
||||
<info>$fullName --flush</info>
|
||||
|
||||
|
||||
Finally, be aware that if <info>--flush</info> option is passed, not all cache providers are able to flush entries,
|
||||
because of a limitation of its execution nature.
|
||||
EOT
|
||||
@ -84,7 +84,7 @@ EOT
|
||||
if ( ! $cacheDriver) {
|
||||
throw new \InvalidArgumentException('No Metadata cache driver is configured on given EntityManager.');
|
||||
}
|
||||
|
||||
|
||||
if ($cacheDriver instanceof Cache\ApcCache) {
|
||||
throw new \LogicException("Cannot clear APC Cache from Console, its shared in the Webserver memory and not accessible from the CLI.");
|
||||
}
|
||||
@ -93,12 +93,12 @@ EOT
|
||||
|
||||
$result = $cacheDriver->deleteAll();
|
||||
$message = ($result) ? 'Successfully deleted cache entries.' : 'No cache entries were deleted.';
|
||||
|
||||
|
||||
if (true === $input->getOption('flush')) {
|
||||
$result = $cacheDriver->flushAll();
|
||||
$message = ($result) ? 'Successfully flushed cache entries.' : $message;
|
||||
}
|
||||
|
||||
|
||||
$output->write($message . PHP_EOL);
|
||||
}
|
||||
}
|
||||
|
@ -51,11 +51,11 @@ class QueryCommand extends Console\Command\Command
|
||||
'If defined, cache entries will be flushed instead of deleted/invalidated.'
|
||||
)
|
||||
));
|
||||
|
||||
|
||||
$fullName = $this->getName();
|
||||
$this->setHelp(<<<EOT
|
||||
The <info>$fullName</info> command is meant to clear the query cache of associated Entity Manager.
|
||||
It is possible to invalidate all cache entries at once - called delete -, or flushes the cache provider
|
||||
It is possible to invalidate all cache entries at once - called delete -, or flushes the cache provider
|
||||
instance completely.
|
||||
|
||||
The execution type differ on how you execute the command.
|
||||
@ -66,7 +66,7 @@ If you want to invalidate the entries (and not delete from cache instance), this
|
||||
Alternatively, if you want to flush the cache provider using this command:
|
||||
|
||||
<info>$fullName --flush</info>
|
||||
|
||||
|
||||
Finally, be aware that if <info>--flush</info> option is passed, not all cache providers are able to flush entries,
|
||||
because of a limitation of its execution nature.
|
||||
EOT
|
||||
@ -84,7 +84,7 @@ EOT
|
||||
if ( ! $cacheDriver) {
|
||||
throw new \InvalidArgumentException('No Query cache driver is configured on given EntityManager.');
|
||||
}
|
||||
|
||||
|
||||
if ($cacheDriver instanceof Cache\ApcCache) {
|
||||
throw new \LogicException("Cannot clear APC Cache from Console, its shared in the Webserver memory and not accessible from the CLI.");
|
||||
}
|
||||
@ -93,12 +93,12 @@ EOT
|
||||
|
||||
$result = $cacheDriver->deleteAll();
|
||||
$message = ($result) ? 'Successfully deleted cache entries.' : 'No cache entries were deleted.';
|
||||
|
||||
|
||||
if (true === $input->getOption('flush')) {
|
||||
$result = $cacheDriver->flushAll();
|
||||
$message = ($result) ? 'Successfully flushed cache entries.' : $message;
|
||||
}
|
||||
|
||||
|
||||
$output->write($message . PHP_EOL);
|
||||
}
|
||||
}
|
||||
|
@ -51,11 +51,11 @@ class ResultCommand extends Console\Command\Command
|
||||
'If defined, cache entries will be flushed instead of deleted/invalidated.'
|
||||
)
|
||||
));
|
||||
|
||||
|
||||
$fullName = $this->getName();
|
||||
$this->setHelp(<<<EOT
|
||||
The <info>$fullName</info> command is meant to clear the result cache of associated Entity Manager.
|
||||
It is possible to invalidate all cache entries at once - called delete -, or flushes the cache provider
|
||||
It is possible to invalidate all cache entries at once - called delete -, or flushes the cache provider
|
||||
instance completely.
|
||||
|
||||
The execution type differ on how you execute the command.
|
||||
@ -66,7 +66,7 @@ If you want to invalidate the entries (and not delete from cache instance), this
|
||||
Alternatively, if you want to flush the cache provider using this command:
|
||||
|
||||
<info>$fullName --flush</info>
|
||||
|
||||
|
||||
Finally, be aware that if <info>--flush</info> option is passed, not all cache providers are able to flush entries,
|
||||
because of a limitation of its execution nature.
|
||||
EOT
|
||||
@ -84,7 +84,7 @@ EOT
|
||||
if ( ! $cacheDriver) {
|
||||
throw new \InvalidArgumentException('No Result cache driver is configured on given EntityManager.');
|
||||
}
|
||||
|
||||
|
||||
if ($cacheDriver instanceof Cache\ApcCache) {
|
||||
throw new \LogicException("Cannot clear APC Cache from Console, its shared in the Webserver memory and not accessible from the CLI.");
|
||||
}
|
||||
@ -93,12 +93,12 @@ EOT
|
||||
|
||||
$result = $cacheDriver->deleteAll();
|
||||
$message = ($result) ? 'Successfully deleted cache entries.' : 'No cache entries were deleted.';
|
||||
|
||||
|
||||
if (true === $input->getOption('flush')) {
|
||||
$result = $cacheDriver->flushAll();
|
||||
$message = ($result) ? 'Successfully flushed cache entries.' : $message;
|
||||
}
|
||||
|
||||
|
||||
$output->write($message . PHP_EOL);
|
||||
}
|
||||
}
|
@ -80,7 +80,7 @@ class ConvertDoctrine1SchemaCommand extends Console\Command\Command
|
||||
if ($this->metadataExporter == null) {
|
||||
$this->metadataExporter = new ClassMetadataExporter();
|
||||
}
|
||||
|
||||
|
||||
return $this->metadataExporter;
|
||||
}
|
||||
|
||||
@ -91,7 +91,7 @@ class ConvertDoctrine1SchemaCommand extends Console\Command\Command
|
||||
{
|
||||
$this->metadataExporter = $metadataExporter;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @see Console\Command\Command
|
||||
*/
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user