모델에 hasMany가있는 "Post"에 연결된 테이블 "Topic"이 있습니다.CakePhp에서 hasMany가있는 테이블에서 여러 레코드를 업데이트 할 수 없습니다.
한 번에 두 테이블을 업데이트하는 방법을 알 수 없습니다.
이
Array
(
[Topic] => Array
(
[id] => 1
[topic_title] => This is my topic
)
[Post] => Array
(
[1] => Array
(
[id] => 1
[title] => Blah
[message] => My message
)
[2] => Array
(
[id] => 2
[title] => Second Blah
[message] => Second My message
)
)
)
내가 이렇게하려고 노력했습니다 내 $ this-> 요청 -> 데이터입니다 :
$this->Topic->save($this->request->data);
$this->loadmodel('Post');
$this->Post->updateAll($this->request->data, array('Post.topic_id' => $id));
이 명확 나는를 찾기 위해 고군분투하지만 잘못된 접근입니다 이것을하는 좋은 방법. 당신이 $this->Topic->save($this->request->data)
를 사용하는 경우