下面我需要更新users表中的一些列。我在代码中使用laravel查询构建器。我想知道用户表是否有更新?
DB::table('users')
->where('id',2)
->update
([
'first_name' => trim($validate->firstName),
'capital' => trim($validate->capital),
'last_name' => trim($validate->lastName),
'town' => trim($validate->town),
'visit_price' => trim($validate->visit),
'consultant_account' => trim($validate->account),
'grade' => trim($validate->grade),
'tel' => trim($validate->tel),
'mobile' => trim($validate->mobile),
'expert' => trim($validate->expert),
'password' => ($validate->pass),
]);
答案 0 :(得分:0)
像这样检查:
$update = DB::table('users')
->where('id',2)
->update
([
'first_name' => trim($validate->firstName),
'capital' => trim($validate->capital),
'last_name' => trim($validate->lastName),
'town' => trim($validate->town),
'visit_price' => trim($validate->visit),
'consultant_account' => trim($validate->account),
'grade' => trim($validate->grade),
'tel' => trim($validate->tel),
'mobile' => trim($validate->mobile),
'expert' => trim($validate->expert),
'password' => ($validate->pass),
]);
if($update !== false){
//updated
}
else
{
//Not updated
}