質問編集履歴
2
キャプチャを追加しまいした。
test
CHANGED
File without changes
|
test
CHANGED
@@ -60,6 +60,10 @@
|
|
60
60
|
|
61
61
|
|
62
62
|
|
63
|
+
![イメージ説明](6f10e41fa105a3f0a10ee6a5fd2b29f4.jpeg)
|
64
|
+
|
65
|
+
|
66
|
+
|
63
67
|
```
|
64
68
|
|
65
69
|
$informations = $this->Informations->find()
|
1
依頼内容が分かりにくいと指摘を頂いたので修正いたしました。
test
CHANGED
@@ -1 +1 @@
|
|
1
|
-
Cakephp3
|
1
|
+
Cakephp3 find エラー
|
test
CHANGED
@@ -1,6 +1,14 @@
|
|
1
|
-
Cakephp3 クエリビルダで困ってます
|
1
|
+
Cakephp3 クエリビルダで困ってます。
|
2
2
|
|
3
3
|
|
4
|
+
|
5
|
+
informationsテーブルにはcase・categoryの2つのテーブルが「多 対 1」の関係でリレーション
|
6
|
+
|
7
|
+
informations_usersテーブルでは「多 対 多」でリレーションしています。
|
8
|
+
|
9
|
+
|
10
|
+
|
11
|
+
```
|
4
12
|
|
5
13
|
CREATE TABLE `informations` (
|
6
14
|
|
@@ -34,9 +42,7 @@
|
|
34
42
|
|
35
43
|
|
36
44
|
|
37
|
-
informationsテーブルにはcase・categoryの2つのテーブルが「多 対 1」の関係でリレーション
|
38
|
-
|
39
|
-
|
45
|
+
```
|
40
46
|
|
41
47
|
|
42
48
|
|
@@ -54,6 +60,46 @@
|
|
54
60
|
|
55
61
|
|
56
62
|
|
63
|
+
```
|
64
|
+
|
65
|
+
$informations = $this->Informations->find()
|
66
|
+
|
67
|
+
->contain(['Cases', 'Categories', 'Users'])
|
68
|
+
|
69
|
+
->where([
|
70
|
+
|
71
|
+
'Informations.title like' => $this->request->data('title'),
|
72
|
+
|
73
|
+
'Informations.projectcase_id' => $this->request->data('case_id'),
|
74
|
+
|
75
|
+
'Informations.projectcase_id' => $this->request->data('category_id'),
|
76
|
+
|
77
|
+
])
|
78
|
+
|
79
|
+
->matching('Users', function($q){
|
80
|
+
|
81
|
+
$person_id = $this->request->session()->read('Auth.User.id');
|
82
|
+
|
83
|
+
$data = $this->request->data('users')[0]['_read_flag'];
|
84
|
+
|
85
|
+
return $q
|
86
|
+
|
87
|
+
->where([
|
88
|
+
|
89
|
+
'InformationsUsers.user_id' => $person_id,
|
90
|
+
|
91
|
+
'InformationsUsers.read_flag' => $data,
|
92
|
+
|
93
|
+
]);
|
94
|
+
|
95
|
+
});
|
96
|
+
|
97
|
+
```
|
98
|
+
|
99
|
+
上記コードではエラーが発生してしまいました。
|
100
|
+
|
101
|
+
|
102
|
+
|
57
103
|
if文ですべてのパターンを書かない方法を教えてください。
|
58
104
|
|
59
105
|
よろしくお願い致します。
|