はじめまして!
現在CakePHPのページング機能(ページネーション)を活用しているのですが、条件($conditons)が付く時は
php
1//PurchasesController.php 2public $paginate = array( 3 'Purchase' => array( 4 //limit, orderの記入 5 ) 6 ); 7 8public function index() { 9 10$conditions = array( 11 //この中に条件記入 12 ); 13 14 $this->set('purchases', $this->paginate($conditions)); 15 16}
とコードを記述すれば良いことは把握しているのですが、
以下のようにテーブルを結合させる$optionsも含まれるfind構文の時どう記述すればよいのかわかりません。
php
1//PurchasesController.php 2 3public function index() { 4 5//PurchaseテーブルとUserテーブルを結合 6$options['joins'] = array( 7 array('table' => 'users', 8 'alias' => 'User', 9 'type' => 'LEFT', 10 'conditions' => array( 11 'User.id = Purchase.user_id', 12 ) 13 ) 14); 15 16 $this->set('purchases', 17$this->Purchase->find('all', array( 18 'conditions' => array( //条件), 19)), 20$options 21); 22 23}
もし何かお分かりの方は、是非ともご教授の程よろしくお願い申し上げます。
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。