1
0
mirror of synced 2025-01-29 19:41:45 +03:00

Add support for IN(?) queries in repositories using the DBAL support for parameter lists.

This commit is contained in:
Benjamin Eberlei 2011-03-06 11:15:56 +01:00
parent 3d37e436dd
commit 03630df20d
4 changed files with 9 additions and 14 deletions

View File

@ -22,6 +22,7 @@ namespace Doctrine\ORM\Persisters;
use PDO,
Doctrine\DBAL\LockMode,
Doctrine\DBAL\Types\Type,
Doctrine\DBAL\Connection,
Doctrine\ORM\ORMException,
Doctrine\ORM\OptimisticLockException,
Doctrine\ORM\EntityManager,
@ -1281,7 +1282,7 @@ class BasicEntityPersister
} else {
throw ORMException::unrecognizedField($field);
}
$conditionSql .= ' = ?';
$conditionSql .= (is_array($value)) ? ' IN (?)' : ' = ?';
}
return $conditionSql;
}
@ -1373,6 +1374,10 @@ class BasicEntityPersister
if (isset($this->_class->fieldMappings[$field])) {
$type = Type::getType($this->_class->fieldMappings[$field]['type'])->getBindingType();
}
if (is_array($value)) {
$type += Connection::ARRAY_PARAM_OFFSET;
}
$params[] = $value;
$types[] = $type;
}

View File

@ -1953,14 +1953,6 @@ class UnitOfWork implements PropertyChangedListener
// TODO: This is very imperformant, ignore it?
$newValue = $this->em->find($assoc['targetEntity'], $associatedId);
}
// TODO: Is there a faster approach?
$this->eagerLoadingEntities[$assoc['targetEntity']] = array_merge_recursive(
$this->eagerLoadingEntities[$assoc['targetEntity']],
array_map(function($id) {
return array($id);
}, $associatedId)
);
} else {
$newValue = $this->em->getProxyFactory()->getProxy($assoc['targetEntity'], $associatedId);
}
@ -2012,8 +2004,6 @@ class UnitOfWork implements PropertyChangedListener
}
/**
<<<<<<< HEAD
=======
* @return void
*/
public function triggerEagerLoads()
@ -2022,6 +2012,7 @@ class UnitOfWork implements PropertyChangedListener
return;
}
// avoid infinite recursion
$eagerLoadingEntities = $this->eagerLoadingEntities;
$this->eagerLoadingEntities = array();
@ -2032,7 +2023,6 @@ class UnitOfWork implements PropertyChangedListener
}
/**
>>>>>>> DDC-952 - Implemented first approach for batching eager loads of ToOne associations.
* Initializes (loads) an uninitialized persistent collection of an entity.
*
* @param PeristentCollection $collection The collection to initialize.

@ -1 +1 @@
Subproject commit 556351d9d6b4a33506f2c1535cccee34faa65d62
Subproject commit 9cd6df38d841abb4719286ea35a1b37aa2679f8d

View File

@ -63,7 +63,7 @@ class DDC633Test extends \Doctrine\Tests\OrmFunctionalTestCase
$this->_em->clear();
$appointments = $this->_em->createQuery("SELECT a FROM " . __NAMESPACE__ . "\DDC633Appointment a")->getResult();
foreach ($appointments AS $eagerAppointment) {
$this->assertType('Doctrine\ORM\Proxy\Proxy', $eagerAppointment->patient);
$this->assertTrue($eagerAppointment->patient->__isInitialized__, "Proxy should already be initialized due to eager loading!");