2012-02-27 5 views
0

저는 정말 이상한 '포함'동작을하고 있습니다. $ restaurant를 주석 처리 할 때마다 $ spas는 beforeFilter()에 할당 된 데이터를 반환하지만 $ 식당의 주석을 제거하면 contains 문을 무시합니다. ($ spas 함수를 복제하고 "$ ? 레스토랑 "과 같은 일이 발생은 ..CakePHP : 이상한 행동을 포함합니다.

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); 
} 
+0

'$ restaurants = $ this-> Coupon-> find ('all', array ('conditions'=> 'category_id'=> 1 ')와 같은 일반적인 찾기 쿼리로 주석 행을 변경해 보았습니까? limit '=> $ showPerPage))'? –

답변

0

당신은

쿠폰 모델에 $actsAs 변수에이 동작을 첨부 않았거나 당신이 컨트롤러에 첨부 할 수 있습니다

$this->Coupon->Behaviors->attach('Containable'); 
$this->Coupon->contain(array('Vendor' => array('VendorLocation'), 'Category')); 

그리고 어디를 분리 원하는 :

$this->Coupon->Behaviors->detach('Containable'); 
관련 문제