0
私はeコマースのウェブサイトで、価格、種類などの事前フィルタが必要です。advance filterでcakephpページネーションを処理しています
コントローラ
public function index($category) {
$this->set('category',$category);
$this->loadModel("Product");
$conditions['Product.category'] = $category;
if(!empty($this->request->data['filter']['materialtype']))
{
foreach($this->request->data['filter']['materialtype'] as $v)
{
$this->set('v',$v);
$conditions['OR'][]['Product.materialtype LIKE'] ="%$v%";
}
}
$this->set('agetProduct',$this->paginate($conditions));
}
最初のクエリWORKING FINE
1 SELECT `Product`.`id`, `Product`.`category`, `Product`.`materialtype`, `Product`.`occasion`, `Product`.`collections`, `Product`.`stone`, `Product`.`sku`, `Product`.`name`, `Product`.`goldkaratage`, `Product`.`weight`, `Product`.`stoneweight`, `Product`.`diamondcaratage`, `Product`.`diamondcolor`, `Product`.`diamondclarity`, `Product`.`picture1`, `Product`.`picture2`, `Product`.`picture3`, `Product`.`picture4`, `Product`.`picture5`, `Product`.`picture6`, `Product`.`price`, `Product`.`description`, `Product`.`featured`, `Product`.`action` FROM `mookim`.`products` AS `Product` WHERE `Product`.`category` = 'Pendant' LIMIT 12
2 SELECT COUNT(*) AS `count` FROM `mookim`.`products` AS `Product` WHERE `Product`.`category` = 'Pendant'
私は以下のクエリADVANCEフィルタチェックボックスをクリックします
もFINE THIS MYSQLのQUERYは、最初のページとREST ON SET 12社の製品は、2ページ目にある14 RECORD
1 SELECT `Product`.`id`, `Product`.`category`, `Product`.`materialtype`, `Product`.`occasion`, `Product`.`collections`, `Product`.`stone`, `Product`.`sku`, `Product`.`name`, `Product`.`goldkaratage`, `Product`.`weight`, `Product`.`stoneweight`, `Product`.`diamondcaratage`, `Product`.`diamondcolor`, `Product`.`diamondclarity`, `Product`.`picture1`, `Product`.`picture2`, `Product`.`picture3`, `Product`.`picture4`, `Product`.`picture5`, `Product`.`picture6`, `Product`.`price`, `Product`.`description`, `Product`.`featured`, `Product`.`action` FROM `mookim`.`products` AS `Product` WHERE `Product`.`category` = 'Pendant' AND ((`Product`.`materialtype` LIKE '%Yellow Gold%') OR (`Product`.`materialtype` LIKE '%White Gold%') OR (`Product`.`materialtype` LIKE '%Silver%')) LIMIT 12
2 SELECT COUNT(*) AS `count` FROM `mookim`.`products` AS `Product` WHERE `Product`.`category` = 'Pendant' AND ((`Product`.`materialtype` LIKE '%Yellow Gold%') OR (`Product`.`materialtype` LIKE '%White Gold%') OR (`Product`.`materialtype` LIKE '%Silver%'))
が含まれていますが、確認することですWHICH GENERATE IS私は次のページをクリックフィルタクエリの次の製品は、MY QUERY COMPLETELY SQLのテーブルのすべてのレコードが含まれ、今私は以下を参照してくださいQUERYを変更し
1 SELECT `Product`.`id`, `Product`.`category`, `Product`.`materialtype`, `Product`.`occasion`, `Product`.`collections`, `Product`.`stone`, `Product`.`sku`, `Product`.`name`, `Product`.`goldkaratage`, `Product`.`weight`, `Product`.`stoneweight`, `Product`.`diamondcaratage`, `Product`.`diamondcolor`, `Product`.`diamondclarity`, `Product`.`picture1`, `Product`.`picture2`, `Product`.`picture3`, `Product`.`picture4`, `Product`.`picture5`, `Product`.`picture6`, `Product`.`price`, `Product`.`description`, `Product`.`featured`, `Product`.`action` FROM `mookim`.`products` AS `Product` WHERE `Product`.`category` = 'Pendant' LIMIT 12, 12 5 5 1
2 SELECT COUNT(*) AS `count` FROM `mookim`.`products` AS `Product` WHERE `Product`.`category` = 'Pendant'