2013-07-26 68 views
0

我有一個表有一些字段,我想更新特定行中的所有列,我們該怎麼做?使用CakePhp中的條件更新表中的所有字段

我要更新這個數組數據到表

    $travel_details=array(
       'userprofile_id'=>$upid, 
       'day'=>$data['day'], 
       'dayNumeric'=>$daynum, 
       'morning_route'=>$morning_route, 
       'morning_time'=>$morning_time, 
       'evening_route'=>$evening_route, 
       'evening_time'=>$evening_time, 
       'traveller' =>$traveller 
      ); 

我使用一個代碼一些條件

  $this->Singleroute->updateAll($travel_details,array('Singleroute.userprofile_id'=>$upid,'Singleroute.daynumeric'=>$daynum, 
      'Singleroute.day'=>$data['day'])); 

但是這個代碼不working..is有什麼辦法來更新al; l連續的字段? this is the table structure

回答

4

$ travel_details應該是這樣的

$travel_details['Singleroute']=array(
       'userprofile_id'=>$upid, 
       'day'=>$data['day'], 
       'dayNumeric'=>$daynum, 
       'morning_route'=>$morning_route, 
       'morning_time'=>$morning_time, 
       'evening_route'=>$evening_route, 
       'evening_time'=>$evening_time, 
       'traveller' =>$traveller 
      ); 

你需要指定領域陣列模式。 現在運行查詢

$this->Singleroute->updateAll($travel_details,array('Singleroute.userprofile_id'=>$upid,'Singleroute.daynumeric'=>$daynum, 
      'Singleroute.day'=>$data['day'])); 

更多在這裏保存數據 http://book.cakephp.org/1.3/en/The-Manual/Developing-with-CakePHP/Models.html#saving-your-data

+0

非常感謝.............. – SibinF

相關問題