質問編集履歴

5

修正

2018/12/26 07:32

投稿

ofuru.no.good
ofuru.no.good

スコア15

test CHANGED
@@ -1 +1 @@
1
- cakePHP3 複合サブクエリ 書き方
1
+ cakePHP3 複合サブクエリ (MySQL) 書き方
test CHANGED
File without changes

4

修正

2018/12/26 07:32

投稿

ofuru.no.good
ofuru.no.good

スコア15

test CHANGED
File without changes
test CHANGED
@@ -6,7 +6,7 @@
6
6
 
7
7
 
8
8
 
9
- 上記のクエリをcakePHP3のクエリビルドに乗っ取って書きたい。
9
+ 上記のクエリをcakePHP3のクエリビルドに則り書きたい。
10
10
 
11
11
 
12
12
 

3

修正

2018/12/26 06:38

投稿

ofuru.no.good
ofuru.no.good

スコア15

test CHANGED
File without changes
test CHANGED
@@ -48,11 +48,11 @@
48
48
 
49
49
 
50
50
 
51
- $faq_log_null = $this->FaqCategories
51
+ $query = $this->FaqCategories
52
52
 
53
53
  ->find()
54
54
 
55
- ->select('id', 'name',$faq_log_null)
55
+ ->select('id', 'name',$subquery) <-select句
56
56
 
57
57
  ->from(['category' => 'cat'])
58
58
 

2

修正

2018/12/26 06:24

投稿

ofuru.no.good
ofuru.no.good

スコア15

test CHANGED
File without changes
test CHANGED
@@ -34,29 +34,27 @@
34
34
 
35
35
 
36
36
 
37
- //
37
+ // クエリ
38
38
 
39
- $subquery = $this->Category
39
+ $subquery = $this->Content
40
40
 
41
41
  ->find()
42
42
 
43
43
  ->select(count('category_id'))
44
44
 
45
- ->from('category' => 'ca')
45
+ ->where(['category_id' => 'cat.id'])
46
46
 
47
- ->where(['category_id' => 'ca.id'])
48
-
49
- ->group(['ca.id','ca.name','category_id']);
47
+ ->group(['cat.id','cat.name','category_id']);
50
48
 
51
49
 
52
50
 
53
- $query = $this->Category
51
+ $faq_log_null = $this->FaqCategories
54
52
 
55
53
  ->find()
56
54
 
57
- ->select('id', 'name',$subquery)
55
+ ->select('id', 'name',$faq_log_null)
58
56
 
59
- ->where(['id' => $content_id])
57
+ ->from(['category' => 'cat'])
60
58
 
61
59
  ->all();
62
60
 

1

修正

2018/12/26 06:22

投稿

ofuru.no.good
ofuru.no.good

スコア15

test CHANGED
File without changes
test CHANGED
@@ -18,11 +18,11 @@
18
18
 
19
19
 
20
20
 
21
- class MngFaqLogsController extends AppController
21
+ class *****Controller extends AppController
22
22
 
23
23
  {
24
24
 
25
- public function categoryLogs()
25
+ public function index()
26
26
 
27
27
  {
28
28
 
@@ -41,6 +41,8 @@
41
41
  ->find()
42
42
 
43
43
  ->select(count('category_id'))
44
+
45
+ ->from('category' => 'ca')
44
46
 
45
47
  ->where(['category_id' => 'ca.id'])
46
48