【发布时间】:2010-10-31 22:36:56
【问题描述】:
我正在使用 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 结果。
【问题讨论】:
-
你能显示结果吗?如果你存储 toArray() 的结果,而不是在 Doctrine_Collection 上调用它会发生什么?
-
jeremy:如果我存储 toArray() 的结果,一切都会按预期开始。