原则 1.2 getResultCache 和左连接
如果我使用关系进行收集而不进行缓存,我有 1 个查询。通过缓存,该查询分为许多小查询。
一个查询:
$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();
非常小的选择查询:
$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();
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();
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您需要将其添加到您的模型类中:
you NEED to add this to your model class: