そんなときは、こうする。
//まずは初期設定オプション。
$default = array(
'conditions' => array(
'teller_id' => 0,//無料占いのみ
'subcontact_count <' => 3
),
'fields' => array('Contact.id','Contact.user_id'),
'order' => array('Contact.id' => 'desc'),
'limit' => 20
);
Array
(
[conditions] => Array
(
[teller_id] => 0
[subcontact_count <] => 3
)
[fields] => Array
(
[0] => Contact.id
[1] => Contact.user_id
)
[order] => Array
(
[Contact.id] => desc
)
[limit] => 20
)
//後で追加したい配列
$newoption = array(
'conditions' => array(
'teller_id' => 5,//無料占いのみ
'subcontact_count <' => 17,
'new' => 'new'
),
'fields' => array('Contact.user','Contact.name'),
'limit' => 17
);
//これを合体
$q = Set::merge($default,$newoption);
//すると後に指定した配列のデータを優先して配列を結合させる
Array
(
[conditions] => Array
(
[teller_id] => 5
[subcontact_count <] => 17
[new] => new
)
[fields] => Array
(
[0] => Contact.id
[1] => Contact.user_id
[2] => Contact.user
[3] => Contact.name
)
[order] => Array
(
[Contact.id] => desc
)
[limit] => 17
)
だから、初期値を最初、結合したいのを後にしとく必要がある。



