Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Adde more BC compatibility in setParameters.

  • Loading branch information...
commit 161ae31a7e044a7f0dda357ed271215f2317e9a5 1 parent b3e7493
@guilhermeblanco guilhermeblanco authored
View
11 lib/Doctrine/ORM/AbstractQuery.php
@@ -186,8 +186,17 @@ function ($parameter) use ($key)
*/
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
8 tests/Doctrine/Tests/ORM/Functional/QueryTest.php
@@ -165,6 +165,14 @@ public function testSetParameters()
$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
*/
Please sign in to comment.
Something went wrong with that request. Please try again.