2014-01-15 75 views
1

例如,如果我们有:CakePHP的:更新的hasMany相关表

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 
       ) 
     ) 
) 

http://book.cakephp.org/2.0/en/models/associations-linking-models-together.html

,我们应该怎么做的评语表的更新,从给定的,所有这些数据提交用户控制器使用一种形式?

这在某种程度上同我的问题在这里:updating related tables in cake,我很遗憾没有得到正确的答案。有人能告诉我这是如何工作的吗?

回答

0

使用$这个 - >用户 - > saveAssociated($ yourArray);

它会保存所有数据相应