cakephp 検索する。
メモ。
Postが親 hasmany
categoryが子 belongTo
>>post.php
public $filterArgs = array(//検索するフィールドと検索方法likeはあいまい検索
array('name' => 'title', 'type' => 'like', 'method' => 'orConditions'),
array('body' => 'title', 'type' => 'like', 'method' => 'orConditions'),
//'keyword' => array('type' => 'like', 'field' => array('title', 'address')),
'category_id' => array('type' => 'value'),
);
>>PostController.php
public $presetVars = array(
array('field' => 'title', 'type' => 'value'),
array('field' => 'address', 'type' => 'value'),
array('field' => 'category_id', 'type' => 'value'),
);
>>index.ctp
echo $this->Form->input('category_id', array('type'=> 'checkbox','class' => 'span12', 'empty' => true));
まだチェックボックスの項目をDBの項目と同様にする処理がまだや。
viewにDBの項目を渡して、表示させて、検索させる。
これは、すぐにできそうな気がスル。