Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/c/71.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
cakephp:update有许多相关的表_Php_Cakephp_Has Many_Insert Update - Fatal编程技术网

cakephp:update有许多相关的表

cakephp:update有许多相关的表,php,cakephp,has-many,insert-update,Php,Cakephp,Has Many,Insert Update,例如,如果我们有: Array ( [User] => Array ( [id] => 121 [name] => Gwoo the Kungwoo [created] => 2007-05-01 10:31:01 ) [Comment] => Array ( [0] => Array

例如,如果我们有:

Array
(
    [User] => Array
        (
            [id] => 121
            [name] => Gwoo the Kungwoo
            [created] => 2007-05-01 10:31:01
        )
    [Comment] => Array
        (
            [0] => Array
                (
                    [id] => 123
                    [user_id] => 121
                    [title] => On Gwoo the Kungwoo
                    [body] => The Kungwooness is not so Gwooish
                    [created] => 2006-05-01 10:31:01
                )
            [1] => Array
                (
                    [id] => 124
                    [user_id] => 121
                    [title] => More on Gwoo
                    [body] => But what of the 'Nut?
                    [created] => 2006-05-01 10:41:01
                )
        )
)

考虑到所有这些数据都是使用一个表单提交的,我们应该如何从用户控制器更新注释表


这和我的问题是一样的:不幸的是,我没有得到正确的答案。有人能告诉我这是怎么回事吗?

使用$this->User->saveAssociated($yourray)


它将相应地保存所有数据

使用Cookbook中描述的saveAll

$this->User->saveAll($data)