Doctrine 1.2 getResultCache and Left Joins

243 views Asked by At

If I use relations for collection without caching, I have 1 query. With caching this query splits into a lot of small queries.

One query:

$foobars = Doctrine_Query::create()
->from('Project_Model_Table table')
->leftJoin('table.Table1 table1')
->leftJoin('table1.Table2 table2')
->leftJoin('table.Table3 table3')
->leftJoin('table3.Table4 as table4')
->orderBy('table.created DESC')
->execute();

Very much small select-queries:

$foobars = Doctrine_Query::create()
->from('Project_Model_Table table')
->leftJoin('table.Table1 table1')
->leftJoin('table1.Table2 table2')
->leftJoin('table.Table3 table3')
->leftJoin('table3.Table4 as table4')
->orderBy('table.created DESC')
->useResultCache(true)
->execute();
1

There are 1 answers

0
jerson On

you NEED to add this to your model class:

//lib/model/Table.class.php

class Table extends BaseTable{
  public function serializeReferences($bool=null)
  {
   return true;
  }
}