1
"쿠폰"컨트롤러가 있습니다. 인덱스() 함수 (즉,)는 각 카테고리에 쿠폰의 소수를 잡고이를 표시 :CakePHP : "보기"수 유지하기
설정된 각 어레이public function index() {
$showPerPage = 4;
$this->Coupon->recursive = 0;
$this->set('restaurants', $this->Coupon->findAllBycategory_id('1', '', '', $showPerPage));
$this->set('entertainment', $this->Coupon->findAllBycategory_id('2', '', '', $showPerPage));
$this->set('spas', $this->Coupon->findAllBycategory_id('3', '', '', $showPerPage));
$this->set('services', $this->Coupon->findAllBycategory_id('4', '', '', $showPerPage));
$this->set('hotels', $this->Coupon->findAllBycategory_id('5', '', '', $showPerPage));
$this->set('retail', $this->Coupon->findAllBycategory_id('6', '', '', $showPerPage));
}
(레스토랑 entertinamnent, 온천 등), I는 각 쿠폰을 필터링 할 "mini_views"카운터를 1로 늘리십시오. "increaseMiniView ($ id)"라는 모델에서 함수를 만들었습니다. 이것을 처리하는 가장 좋은 방법은 무엇입니까? 나는 각자를 통해 단지 foreach를 할 수 있다는 것을 알고 있지만 더 좋은 방법이 있는지 나는 알지 못했다. (나는 코드를보기에 넣을 수도 있지만, 그 중 가장 좋은 방법이다).
정확합니다. 또한 루프를'Set :: extract'에 위임 할 수 있습니다. – bfavaretto