各々の顧客の為のサービスを毎月の日付範囲内で特定しようと考えています。
ためしに、TestSummariesコントローラーに下記のコードを作ってみました。
public function view($id=null){
$this->loadModel('Event');
$sum = $this->TestSummary->find('first', array('conditions' => array('TestSummary.id' => $id)));
$first = date('Y-m-01', strtotime($sum['TestSummary']['date']));
$this->set('first', $first);
$last = date('Y-m-t', strtotime($sum['TestSummary']['date']));
$this->set('last', $last);
$cond = array("'MonthEvent.start' >=" => $first, "'MonthEvent.start' <=" => $last,
'MonthEvent.customer_id' => 'TestSummary.customer_id'
);
$this->set('monthevents', $this->MonthEvent->find('all', array('conditions' => $conditions)));
しかし$monthevents変数が、Viewでは空になっています。
customer_id条件を削除して日付範囲のテストもしてみたのですが、どうも問題は'MonthEvent.start'が正しく比較対照されていないことにあるようです。
また、date()関数はクオートの中では使えません。
この問題に対して、どなたかアドバイスをしていただけないでしょうか。よろしくお願いします。
回答1件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。