简体   繁体   中英

SQLSTATE[42S22]: Column not found: 1054 Unknown column '0' in 'field list Laravel

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 ?

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

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM