質問編集履歴

1

修正

2016/09/27 15:43

投稿

yajin
yajin

スコア75

test CHANGED
File without changes
test CHANGED
@@ -71,3 +71,35 @@
71
71
  $this->set('samples', $this->sampledatas->find()->limit(10));
72
72
 
73
73
  ```
74
+
75
+
76
+
77
+
78
+
79
+ ただ単に取得したい場合
80
+
81
+ ```PHP
82
+
83
+ public function home(){
84
+
85
+ $this->ViewBuilder()->layout('auth');
86
+
87
+ $articles = TableRegistry::get('articles');
88
+
89
+ $user_id = $this->request->session()->read('Auth.User.id');
90
+
91
+ $query = $articles->find();
92
+
93
+ $query = $articles->find('all', [
94
+
95
+ 'where' => ['Articles.user_id' => $user_id]
96
+
97
+ ]);
98
+
99
+ $number = $query->count();
100
+
101
+ $this->set('number', $number);
102
+
103
+ }
104
+
105
+ ```