我有两个控制器我应该在这种情况下使用更多的查找吗?
Sections_controller.php
Articles_controller.php
Section model hasmany Article...
我想获取文章像所有新闻sites..every块块的形式有链接到本section..so我用这个代码中的物品节的名称。 ..... 第一块
$block1=$this->Article->find('all',
array(
'limit' => 4, // just fetch 4 articles
'order' => array('Article.created'=>'DESC'),
'conditions' => array('Section_id' => 87)
)
);
// set the section for the view
$this->set(compact('block1'));
第二块
$block2=$this->Article->find('all',
array(
'limit' => 4, // just fetch 4 articles
'order' => array('Article.created'=>'DESC'),
'conditions' => array('Section_id' => 88)
)
);
// set the section for the view
$this->set(compact('block2'));
和等....
任何人有这个任务的最佳方法,无需重复查找代码.. 通知功能 ..我着通$ ID,因为文章必须显示当请求站点索引的例子(WWW .newssite.com)
谢谢..我喜欢第一个代码块..但还有一个问题关于“胖模型,皮包骨头控制器”的原理..如果我遵循这个原则,它会运行我的脚本快速或降低带宽?..谢谢 – user1080247 2012-01-09 04:27:48
我相信它更多的是关于速度或带宽的代码组织。 – Dave 2012-01-09 13:25:33