Column not found: 1054 Unknown column '0' in 'field list' - Laravel - I don't have a 0 column anywhere in my code

后端 未结 4 1581
悲&欢浪女
悲&欢浪女 2021-02-13 11:24

I\'m getting this weird error:

SQLSTATE[42S22]: Column not found: 1054 Unknown column \'0\' in \'field list\' (SQL: update forum_threads set

4条回答
  •  Happy的楠姐
    2021-02-13 11:41

    The error is due to ->update(['locked', 1]); which should be ->update(['locked' => 1]);

    the update function uses an array as "column" => "value", your syntax error causes Laravel to think [ 0 => 'locked', 1 => 1], so it translates to this SQL SET 0 = 'locked', 1 = 1...

提交回复
热议问题