Made setParameters()/excute()/iterate() BC compatible.
This commit is contained in:
parent
d8e165da8d
commit
b3e7493278
3 changed files with 21 additions and 13 deletions
|
@ -180,12 +180,16 @@ abstract class AbstractQuery
|
||||||
/**
|
/**
|
||||||
* Sets a collection of query parameters.
|
* Sets a collection of query parameters.
|
||||||
*
|
*
|
||||||
* @param \Doctrine\Common\Collections\ArrayCollection $parameters
|
* @param \Doctrine\Common\Collections\ArrayCollection|array $parameters
|
||||||
*
|
*
|
||||||
* @return \Doctrine\ORM\AbstractQuery This query instance.
|
* @return \Doctrine\ORM\AbstractQuery This query instance.
|
||||||
*/
|
*/
|
||||||
public function setParameters(ArrayCollection $parameters)
|
public function setParameters($parameters)
|
||||||
{
|
{
|
||||||
|
if (is_array($parameters)) {
|
||||||
|
$parameters = new ArrayCollection($parameters);
|
||||||
|
}
|
||||||
|
|
||||||
$this->parameters = $parameters;
|
$this->parameters = $parameters;
|
||||||
|
|
||||||
return $this;
|
return $this;
|
||||||
|
@ -659,17 +663,17 @@ abstract class AbstractQuery
|
||||||
* Executes the query and returns an IterableResult that can be used to incrementally
|
* Executes the query and returns an IterableResult that can be used to incrementally
|
||||||
* iterate over the result.
|
* iterate over the result.
|
||||||
*
|
*
|
||||||
* @param \Doctrine\Common\Collections\ArrayCollection $parameters The query parameters.
|
* @param \Doctrine\Common\Collections\ArrayCollection|array $parameters The query parameters.
|
||||||
* @param integer $hydrationMode The hydration mode to use.
|
* @param integer $hydrationMode The hydration mode to use.
|
||||||
* @return \Doctrine\ORM\Internal\Hydration\IterableResult
|
* @return \Doctrine\ORM\Internal\Hydration\IterableResult
|
||||||
*/
|
*/
|
||||||
public function iterate(ArrayCollection $parameters = null, $hydrationMode = null)
|
public function iterate($parameters = null, $hydrationMode = null)
|
||||||
{
|
{
|
||||||
if ($hydrationMode !== null) {
|
if ($hydrationMode !== null) {
|
||||||
$this->setHydrationMode($hydrationMode);
|
$this->setHydrationMode($hydrationMode);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($parameters) {
|
if ( ! empty($parameters)) {
|
||||||
$this->setParameters($parameters);
|
$this->setParameters($parameters);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -683,17 +687,17 @@ abstract class AbstractQuery
|
||||||
/**
|
/**
|
||||||
* Executes the query.
|
* Executes the query.
|
||||||
*
|
*
|
||||||
* @param \Doctrine\Common\Collections\ArrayCollection $parameters Query parameters.
|
* @param \Doctrine\Common\Collections\ArrayCollection|array $parameters Query parameters.
|
||||||
* @param integer $hydrationMode Processing mode to be used during the hydration process.
|
* @param integer $hydrationMode Processing mode to be used during the hydration process.
|
||||||
* @return mixed
|
* @return mixed
|
||||||
*/
|
*/
|
||||||
public function execute(ArrayCollection $parameters = null, $hydrationMode = null)
|
public function execute($parameters = null, $hydrationMode = null)
|
||||||
{
|
{
|
||||||
if ($hydrationMode !== null) {
|
if ($hydrationMode !== null) {
|
||||||
$this->setHydrationMode($hydrationMode);
|
$this->setHydrationMode($hydrationMode);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($parameters) {
|
if ( ! empty($parameters)) {
|
||||||
$this->setParameters($parameters);
|
$this->setParameters($parameters);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -526,11 +526,11 @@ final class Query extends AbstractQuery
|
||||||
* Executes the query and returns an IterableResult that can be used to incrementally
|
* Executes the query and returns an IterableResult that can be used to incrementally
|
||||||
* iterated over the result.
|
* iterated over the result.
|
||||||
*
|
*
|
||||||
* @param \Doctrine\Common\Collections\ArrayCollection $parameters The query parameters.
|
* @param \Doctrine\Common\Collections\ArrayCollection|array $parameters The query parameters.
|
||||||
* @param integer $hydrationMode The hydration mode to use.
|
* @param integer $hydrationMode The hydration mode to use.
|
||||||
* @return \Doctrine\ORM\Internal\Hydration\IterableResult
|
* @return \Doctrine\ORM\Internal\Hydration\IterableResult
|
||||||
*/
|
*/
|
||||||
public function iterate(ArrayCollection $parameters = null, $hydrationMode = self::HYDRATE_OBJECT)
|
public function iterate($parameters = null, $hydrationMode = self::HYDRATE_OBJECT)
|
||||||
{
|
{
|
||||||
$this->setHint(self::HINT_INTERNAL_ITERATION, true);
|
$this->setHint(self::HINT_INTERNAL_ITERATION, true);
|
||||||
|
|
||||||
|
|
|
@ -14,6 +14,7 @@ class HydrationCacheTest extends OrmFunctionalTestCase
|
||||||
public function setUp()
|
public function setUp()
|
||||||
{
|
{
|
||||||
$this->useModelSet('cms');
|
$this->useModelSet('cms');
|
||||||
|
|
||||||
parent::setUp();
|
parent::setUp();
|
||||||
|
|
||||||
$user = new CmsUser;
|
$user = new CmsUser;
|
||||||
|
@ -72,14 +73,17 @@ class HydrationCacheTest extends OrmFunctionalTestCase
|
||||||
$user = new CmsUser();
|
$user = new CmsUser();
|
||||||
$user->id = 1;
|
$user->id = 1;
|
||||||
|
|
||||||
$dql = "SELECT u FROM Doctrine\Tests\Models\Cms\CmsUser u WHERE u.id = ?1";
|
$dql = "SELECT u FROM Doctrine\Tests\Models\Cms\CmsUser u WHERE u.id = ?1";
|
||||||
$query = $this->_em->createQuery($dql)
|
$query = $this->_em->createQuery($dql)
|
||||||
->setParameter(1, $user)
|
->setParameter(1, $user)
|
||||||
->setHydrationCacheProfile(new QueryCacheProfile(null, null, $cache));
|
->setHydrationCacheProfile(new QueryCacheProfile(null, null, $cache));
|
||||||
|
|
||||||
$query->getResult();
|
$query->getResult();
|
||||||
|
|
||||||
$c = $this->getCurrentQueryCount();
|
$c = $this->getCurrentQueryCount();
|
||||||
|
|
||||||
$query->getResult();
|
$query->getResult();
|
||||||
|
|
||||||
$this->assertEquals($c, $this->getCurrentQueryCount(), "Should not execute query. Its cached!");
|
$this->assertEquals($c, $this->getCurrentQueryCount(), "Should not execute query. Its cached!");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue