php – Doctrine ORM,两个不同的查询生成相同的结果集

我正在使用Doctrine 1.2和Symfony 1.4.

在我的操作中,我有两个不同的查询返回不同的结果集.不知怎的,第二个查询似乎改变了第一个查询的结果(或引用?),我没有任何线索为什么..

这是一个例子:

  $this->categories = Doctrine_Query::create()
       ->from('Categorie AS c')
       ->innerJoin('c.Activite AS a')
       ->where('a.archive = ?', false)
       ->execute();

  print_r($this->categories->toArray()); // Return $this->categories results, normal behavior.

  $this->evil_query = Doctrine_Query::create()
       ->from('Categorie AS c')
       ->innerJoin('c.Activite AS a')
       ->where('a.archive = ?', true)
       ->execute();

  print_r($this->categories->toArray()); // Should be the same as before, but it return $this->evil_query results instead!

为什么Doctrine这样做?这让我疯狂.谢谢!

为简单起见,似乎查询2正在劫持查询1结果.

解决方法:

在Doctrine_Collection中的toArray()方法api文档中,它说:

Mimics the result of a $query->execute(array(), Doctrine_Core::HYdratE_ARRAY);

我怀疑你满意地回答这个问题,你将不得不通过源代码.

相关文章

统一支付是JSAPI/NATIVE/APP各种支付场景下生成支付订单,返...
统一支付是JSAPI/NATIVE/APP各种支付场景下生成支付订单,返...
前言 之前做了微信登录,所以总结一下微信授权登录并获取用户...
FastAdmin是我第一个接触的后台管理系统框架。FastAdmin是一...
之前公司需要一个内部的通讯软件,就叫我做一个。通讯软件嘛...
统一支付是JSAPI/NATIVE/APP各种支付场景下生成支付订单,返...