find条件とか、unbindModelのメモ
自分用メモ
findの条件でcurrent_date使う場合。配列のキーを指定せずに、値に全部入れる
<php $field = array( 'id' ); $cond = array( 'activeid' => $id, 'status' => 1, 'activeid_expire >= current_date' ); $result = $this->find( 'first', array( 'conditions' => $cond, 'fields' => $field ) );
Findの条件指定は下記に色々と書いてある
http://book.cakephp.org/ja/view/74/Complex-Find-Conditions
findの第1引数で指定できるもの
(all / first / count / neighbors / list / threaded )
unbindModelについて
hasManyとかしてる場合、必要なければ一時的にアソシエーションをはずす(下記はmodel内のメソッドで実行する場合)
<?php $this->unbindModel(array('hasMany'=>array('Post')));
一時的じゃなくて恒久的にアソシエーションをはずす場合は、第2引数にfalseを指定する
<?php $this->unbindModel(array('hasMany'=>array('Post')),false);