I write a lumen code to update my table fields, this is my code -
$field='';
if($request->input('category')){
$val=$request->input('category');
$field="'category' => '$val'";
}
if($request->input('subcategory')){
$val=$request->input('subcategory');
if($field==''){
$field="'sub_category' => '$val'";
}else{
$field.=",'sub_category' => '$val'";
}
}
// return $field;
$Expence=DB::table('expencedetails')->where('id',$request->input('id'))->update(['$field']);
the value of $filed is 'category' => 'fgfg','sub_category' => 'ggg'.
when I run the code it shows an error SQLSTATE[42S22]: Column not found: 1054 Unknown column '0' in 'field list' (SQL: update expencedetails
set 0
= $field where id
= 1)
from Newest questions tagged laravel-5 - Stack Overflow http://ift.tt/2DWYJ5l
via IFTTT
Aucun commentaire:
Enregistrer un commentaire