Strange behavior with doctrine_record::free() method on a loop
Hie all,
I loop in Doctrine_Query::exec开发者_如何学编程ute() with many relations and i get a record on each iteration. No problem.
To save memory, i would like free() record memory usage with Doctrine_Record::free().
The first iteration, no problem but at the next one my new object loose relation. Example :
$q = Doctrine_Query::create()
->From(..)
->leftJoin(...)
->innerJoin(Relationship)
->where(...)
->andWhere(...);
foreach($q->execute() as $r)
{
$val = $r->Relationship->get(colx);
$r->free(true);
}
At the second iteration, i get new record but without innerJoin Relationship ???
Any idea...
Thanks for your advice
As it states in the method comments and the API reference
Helps freeing the memory occupied by the entity. Cuts all references the entity has to other entities and removes the entity from the instance pool. Note: The entity is no longer useable after free() has been called. Any operations done with the entity afterwards can lead to unpredictable results.
You shouldn't use free()
, especially if you intend to use the record afterwards. The only case you should need to use it is if you're loading an extremely large number of records and you need to free up memory.
精彩评论