diff --git a/lib/Doctrine/ORM/AbstractQuery.php b/lib/Doctrine/ORM/AbstractQuery.php index 94a76f641..d3e661071 100644 --- a/lib/Doctrine/ORM/AbstractQuery.php +++ b/lib/Doctrine/ORM/AbstractQuery.php @@ -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; diff --git a/tests/Doctrine/Tests/ORM/Functional/QueryTest.php b/tests/Doctrine/Tests/ORM/Functional/QueryTest.php index 19a804b4d..fd1e14703 100644 --- a/tests/Doctrine/Tests/ORM/Functional/QueryTest.php +++ b/tests/Doctrine/Tests/ORM/Functional/QueryTest.php @@ -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 */