Reputation: 846
I have following function code in my Controller
public function processEdit($inputs) {
$id = Input::get('id');
$user = new User($inputs);
$result = User::where('id', '=', $id)->update(array($user));
return view ('welcome');
}
after executing this code i am getting following error
SQLSTATE[42S22]: Column not found: 1054 Unknown column '0' in 'field list
I have not any column in my table , or my inputs. Any help ?
Upvotes: 2
Views: 5710
Reputation: 146
hello guys i think it's because you are using 2d array
$orderArr=array($order);
so your $orderArr is will be some thing like this:
$orderArr=array:2 [▼
2 => "2"
4 => "4"
])
i had this problem because i was using some thing like this in my view
<input name="media[{{$media->id}}]"
after i changed it to
<input name="{{$media->id}}]"
my problem vanished
Upvotes: 1
Reputation: 34914
I guess you are using php framework laravel
, just use $inputs
instead of array($user)
$result = User::where('id', '=', $id)->update($inputs);
Be sure $inputs
is a array like this
$inputs = ["col1"=>"value1","col2"=>"value2"]
Get more detail from Docs : https://laravel.com/docs/master/eloquent#updates
Upvotes: 2