Doctrine 1.2: Disabling Caching

Similar to this question, I had some problems with how the doctrine caches / moistens the relationships of the result of my query.

Now I know that I can fix the problem by calling refresh / refreshRelated, but is there a way to disable the hydration cache for the / temporary table? Especially when using joins in select, so that the example code becomes:

$result2 = Doctrine_Query::create() ->leftJoin('s.School sc') ->from('Student s') ->execute(); 

you really want Doctrine to use the data from your connection instead of using the cached hydrated result from the previous selection.

Is there any way to do this?

Thanks in advance!

+4
source share
2 answers

I think it should dampen the default query result if you have not changed Doctrine_Core::ATTR_HYDRATE_OVERWRITE . You can check the value with:

 $doctrineManager = Doctrine_Manager::getInstance(); $val = $doctrineManager->getAttribute(Doctrine::ATTR_HYDRATE_OVERWRITE); 

When you call refresh (), it sets this to true, and again executes the request, and then restores the parameter. If your case turned out to be false, you can change it using $doctrineManager->setAttribute

+2
source

I think your solution with refreshRelated is fine, but if you don't need these items in the cache. You can set

 Doctrine_Manager::connection()->setAttribute(Doctrine_Core::ATTR_AUTO_FREE_QUERY_OBJECTS, true ); 

Thus, Doctrine will automatically call free () for each request at the end, so it will not cache its result, and will also reduce the amount of memory lower.

0
source

All Articles