2014-01-15 110 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);

它會保存所有數據相應