2017-01-23 64 views
0

我有一個項目表,它包含了2場:PLEVEL1和PRINTOU3:Laravel更新領域,與其他字段值

我發送到更新功能百分比參數,我想更新PLEVEL1 WITH PRINTOUT3像這樣:

public function updatePrice($brandid, $itemgroup, $percentage){ 
$update=DB::table('sd_salesitems')->where('BRAND_ID', $brandid) 
            ->where('SL_GROUP', $itemgroup) 
     ->update(array('PLEVEL1' => 'PRINTOUT3'+'PRINTOUT3'*$percentage/100)); } 

它更新到0,這是不正確的,任何想法?

回答

2

您可以使用此:

DB::table('sd_salesitems') 
     ->update([ 
      "bumped_last" => DB::raw("`PRINTOUT3 `+`PRINTOUT3`*".($percentage/100)) 
     ]); 
+0

工作,謝謝 –