I'm getting this weird error:
SQLSTATE[42S22]:未找到列:‘field list’中有
forum_threads
4个未知列‘0’(sql:updateforum_threads
set0
=LOCKED,1
=1,updated_at
=2016-03-17 16:01:59,其中topic_id
=3,forum_threads
.deleted_at
为NULL)
问题是,我没有0列.我的代码中没有带0
的where子句.我使用的是范围查询.
My controller is:
$action = $request->input('action');
$topic = $request->input('topic');
$thread = Thread::where('topic_id', $topic);
switch ($action) {
case ('locked'):
$thread->lock();
break;
}
正如你所见,我做的不多.我只是想锁住一根线.我正在调用我的Thread
型号的锁定范围.我有很多switch 箱,其中一个是lock
.我已经在顶部运行了一半的查询,所以我不必重复我自己.我只是将其存储在$thread
变量中,以便执行$thread->delete()
和$thread->restore()
之类的操作.
我在线程模型中的查询范围:
public function scopeLock($query)
{
return $query->where('locked', 0)->update(['locked', 1]);
}
That's it. I think it may because I have a where clause passing from my controller (Thread::where('topic_id', $topic)
) and I'm just continuing it onto my scope.
Any help is highly appreciated.