Hub*_*ron 4 php orm doctrine symfony1
我正在使用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!
Run Code Online (Sandbox Code Playgroud)
为什么Doctrine这样做?这让我疯狂.谢谢!
为简单起见,似乎查询2正在劫持查询1结果.
小智 5
在查询之间使用类似的东西($em- 实体管理器):
$em->clear(); // Detaches all objects from Doctrine!
Run Code Online (Sandbox Code Playgroud)
http://docs.doctrine-project.org/en/2.0.x/reference/batch-processing.html