用多个值更新1行1列

时间:2019-12-13 04:15:15

标签: laravel

我的代码有问题。

$id = DB::table('sn_project_details')->insertGetId([
            'emp_name' => $request->emp_name,
            'emp_id' => $request->emp_id,
            'department' => $request->department,
            'submit_date' => $request->submit_date,
            'total_amount' => $request->total_amount,
            'project_tittle' => $request->project_tittle,
            'project_desc' => $request->project_desc,
            'scope' => $request->scope,
            'file' => $request->file
            ]);
//Update Table 
\DB::table('sn_project_details')
      ->where('project_id', $id)
      ->update(['doc_ref' => "ID_",$request->scope,"_",$id]);

return redirect('/user')

我想用示例值 ID_Scope_220 更新doc_ref列, ID_其固定值。范围来自文本框范围。来自@emp_id的220。 但是当我执行此代码时,更新查询无法正常工作。 有人可以帮忙吗?

1 个答案:

答案 0 :(得分:1)

使用点代替逗号

->update(['doc_ref' => "ID_".$request->scope."_".$emp_id]);