【发布时间】:2012-02-27 21:42:29
【问题描述】:
我有一些非常奇怪的“包含”行为。每当我留下 $restaurants 注释时,$spas 都会返回包含的数据(在 beforeFilter() 中分配,但是当我取消注释 $restaurants 时,它会忽略包含语句。(我什至尝试克隆 $spas 函数并将其命名为“$餐馆”,同样的事情也会发生..
class CouponsController extends AppController {
public function beforeFilter() {
parent::beforeFilter();
$this->Coupon->contain(array('Vendor' => array('VendorLocation'), 'Category'));
}
public function index() {
$showPerPage = 4;
//$restaurants = $this->Coupon->findAllBycategory_id('1', '', '', $showPerPage);
$spas = $this->Coupon->find('all', array('limit' => $showPerPage, 'conditions' => array('Coupon.category_id' => 3)));
$this->set('spas', $spas);
}
【问题讨论】:
-
您是否尝试过将注释行更改为像
$restaurants = $this->Coupon->find('all', array('conditions' => 'category_id' => 1, 'limit' => $showPerPage))这样的常规查找查询?
标签: cakephp