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

Adde more BC compatibility in setParameters.

This commit is contained in:
Guilherme Blanco 2012-05-29 14:41:32 -04:00
parent b3e7493278
commit 161ae31a7e
2 changed files with 18 additions and 1 deletions

View File

@ -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;

View File

@ -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
*/