Adde more BC compatibility in setParameters.
This commit is contained in:
parent
b3e7493278
commit
161ae31a7e
@ -186,8 +186,17 @@ abstract class AbstractQuery
|
||||
*/
|
||||
public function setParameters($parameters)
|
||||
{
|
||||
// BC compatibility with 2.3-
|
||||
if (is_array($parameters)) {
|
||||
$parameters = new ArrayCollection($parameters);
|
||||
$parameterCollection = new ArrayCollection();
|
||||
|
||||
foreach ($parameters as $key => $value) {
|
||||
$parameter = new Query\Parameter($key, $value);
|
||||
|
||||
$parameterCollection->add($parameter);
|
||||
}
|
||||
|
||||
$parameters = $parameterCollection;
|
||||
}
|
||||
|
||||
$this->parameters = $parameters;
|
||||
|
@ -165,6 +165,14 @@ class QueryTest extends \Doctrine\Tests\OrmFunctionalTestCase
|
||||
$users = $q->getResult();
|
||||
}
|
||||
|
||||
public function testSetParametersBackwardsCompatible()
|
||||
{
|
||||
$q = $this->_em->createQuery('SELECT u FROM Doctrine\Tests\Models\CMS\CmsUser u WHERE u.name = ?1 AND u.status = ?2');
|
||||
$q->setParameters(array(1 => 'jwage', 2 => 'active'));
|
||||
|
||||
$users = $q->getResult();
|
||||
}
|
||||
|
||||
/**
|
||||
* @group DDC-1070
|
||||
*/
|
||||
|
Loading…
x
Reference in New Issue
Block a user