質問編集履歴
1
test
CHANGED
File without changes
|
test
CHANGED
@@ -1,57 +1,27 @@
|
|
1
1
|
各々の顧客の為のサービスを毎月の日付範囲内で特定しようと考えています。
|
2
|
-
|
3
|
-
|
4
2
|
|
5
3
|
ためしに、TestSummariesコントローラーに下記のコードを作ってみました。
|
6
4
|
|
5
|
+
public function view($id=null){
|
6
|
+
$this->loadModel('Event');
|
7
|
+
$sum = $this->TestSummary->find('first', array('conditions' => array('TestSummary.id' => $id)));
|
8
|
+
$first = date('Y-m-01', strtotime($sum['TestSummary']['date']));
|
7
9
|
|
10
|
+
$this->set('first', $first);
|
8
11
|
|
9
|
-
|
12
|
+
$last = date('Y-m-t', strtotime($sum['TestSummary']['date']));
|
10
13
|
|
11
|
-
|
14
|
+
$this->set('last', $last);
|
12
15
|
|
13
|
-
$this->loadModel('Event');
|
14
|
-
|
15
|
-
$sum = $this->TestSummary->find('first', array('conditions' => array('TestSummary.id' => $id)));
|
16
|
-
|
17
|
-
$first = date('Y-m-01', strtotime($sum['TestSummary']['date']));
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
$this->set('first', $first);
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
$last = date('Y-m-t', strtotime($sum['TestSummary']['date']));
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
$this->set('last', $last);
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
16
|
+
$cond = array("'MonthEvent.start' >=" => $first, "'MonthEvent.start' <=" => $last,
|
34
|
-
|
35
|
-
|
17
|
+
'MonthEvent.customer_id' => 'TestSummary.customer_id'
|
36
|
-
|
37
|
-
|
18
|
+
);
|
38
|
-
|
39
|
-
|
19
|
+
$this->set('monthevents', $this->MonthEvent->find('all', array('conditions' => $conditions)));
|
40
|
-
|
41
|
-
```
|
42
|
-
|
43
|
-
|
44
20
|
|
45
21
|
しかし$monthevents変数が、Viewでは空になっています。
|
46
22
|
|
47
|
-
|
48
|
-
|
49
|
-
customer_id条件を削除して日付範囲のテストもしてみたのですが、どうも問題は
|
23
|
+
customer_id条件を削除して日付範囲のテストもしてみたのですが、どうも問題は'MonthEvent.start'が正しく比較対照されていないことにあるようです。
|
50
|
-
|
51
|
-
|
52
24
|
|
53
25
|
また、date()関数はクオートの中では使えません。
|
54
26
|
|
55
|
-
|
56
|
-
|
57
27
|
この問題に対して、どなたかアドバイスをしていただけないでしょうか。よろしくお願いします。
|