我正在使用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这样做?这让我疯狂.谢谢!
解决方法:
在Doctrine_Collection中的toArray()方法的api文档中,它说:
Mimics the result of a
$query->execute(array(), Doctrine_Core::HYdratE_ARRAY);
我怀疑你满意地回答这个问题,你将不得不通过源代码.