回答編集履歴
1
補足
answer
CHANGED
@@ -7,4 +7,18 @@
|
|
7
7
|
$newData->name = $nameVal;
|
8
8
|
$table->save($newData);
|
9
9
|
}
|
10
|
-
```
|
10
|
+
```
|
11
|
+
|
12
|
+
----
|
13
|
+
|
14
|
+
余談ですが...
|
15
|
+
ControllerでTableにアクセスする場合、TableRegistry::get()よりloadModel()を使うのが一般的です。
|
16
|
+
```php
|
17
|
+
public function test(){
|
18
|
+
$this->loadModel('Hogehoges');
|
19
|
+
$entity = $this->Hogehoges->newEntity();
|
20
|
+
$entity->name = $this->request->query('name');
|
21
|
+
$this->Hogehoges->save($entity);
|
22
|
+
}
|
23
|
+
```
|
24
|
+
※必要ならクエリパラメータがなければ保存しないとか入れておいたほうがいいかもしれませんね。
|