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('ta开发者_高级运维ble.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();
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;
}
}
精彩评论