久久久久久久av_日韩在线中文_看一级毛片视频_日本精品二区_成人深夜福利视频_武道仙尊动漫在线观看

未找到列:“字段列表"中的 1054 列“0"未知

Column not found: 1054 Unknown column #39;0#39; in #39;field list#39; - Laravel - I don#39;t have a 0 column anywhere in my code(未找到列:“字段列表中的 1054 列“0未知 - Laravel - 我的代碼中的任何地方都沒有 0 列)
本文介紹了未找到列:“字段列表"中的 1054 列“0"未知 - Laravel - 我的代碼中的任何地方都沒有 0 列的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

問題描述

我收到這個奇怪的錯誤:

I'm getting this weird error:

SQLSTATE[42S22]:未找到列:1054 '字段列表'中的未知列 '0'(SQL:更新 forum_threads set 0 = 鎖定,1 = 1, updated_at = 2016-03-17 16:01:59 where topic_id = 3 and forum_threads.deleted_at 為空)

SQLSTATE[42S22]: Column not found: 1054 Unknown column '0' in 'field list' (SQL: update forum_threads set 0 = locked, 1 = 1, updated_at = 2016-03-17 16:01:59 where topic_id = 3 and forum_threads.deleted_at is null)

問題是,我沒有 0 列.我的代碼中的任何地方都沒有帶有 0 的 where 子句.我正在使用范圍查詢.

The thing is, I don't have a 0 column. I don't have a where clause with a 0 anywhere in my code. I am using a scope query.

我的控制器是:

    $action = $request->input('action');
    $topic = $request->input('topic');
    $thread = Thread::where('topic_id', $topic);

    switch ($action) {
        case ('locked'):
            $thread->lock();
            break;
    }

如你所見,我做的不多.我只是想鎖定一個線程.我在我的 Thread 模型中調用鎖作用域.我有很多開關盒,其中之一是lock.我已經在頂部運行了一半的查詢,所以我不必重復自己.我只是將它存儲在 $thread 變量中,以便我可以執行諸如 $thread->delete()$thread->restore() 之類的操作.

As you can see, I don't do much. I am just trying to lock a thread. I am calling the lock scope in my Thread model. I have a lot of switch cases, one of which is lock. I have run half of the query at the top so I don't have to repeat myself. I simply stored it in the $thread variable so that I can perform actions like $thread->delete() and $thread->restore().

我在線程模型中的查詢范圍:

My query scope in Thread model:

public function scopeLock($query)
{
    return $query->where('locked', 0)->update(['locked', 1]);
}

就是這樣.我認為這可能是因為我有一個從我的控制器 (Thread::where('topic_id', $topic)) 傳遞過來的 where 子句,而我只是將它繼續到我的范圍內.

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.

非常感謝任何幫助.

推薦答案

錯誤是由于 ->update(['locked', 1]); 應該是 ->update(['locked' => 1]);

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

更新函數使用數組作為列"=>值",你的語法錯誤導致 Laravel 認為 [ 0 =>'鎖定',1 =>1],所以它轉換成這個 SQL SET 0 = 'locked', 1 = 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...

這篇關于未找到列:“字段列表"中的 1054 列“0"未知 - Laravel - 我的代碼中的任何地方都沒有 0 列的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!

【網站聲明】本站部分內容來源于互聯網,旨在幫助大家更快的解決問題,如果有圖片或者內容侵犯了您的權益,請聯系我們刪除處理,感謝您的支持!

相關文檔推薦

Magento products by categories(按類別劃分的 Magento 產品)
Resource interpreted as image but transferred with MIME type text/html - Magento(資源被解釋為圖像但使用 MIME 類型 text/html 傳輸 - Magento)
Is there an event for customer account registration in Magento?(Magento 中是否有客戶帳戶注冊事件?)
Magento addFieldToFilter: Two fields, match as OR, not AND(Magento addFieldToFilter:兩個字段,匹配為 OR,而不是 AND)
quot;Error 404 Not Foundquot; in Magento Admin Login Page(“未找到錯誤 404在 Magento 管理員登錄頁面)
Get Order Increment Id in Magento(在 Magento 中獲取訂單增量 ID)
主站蜘蛛池模板: 国产四区 | 91丨九色丨国产在线 | 国产一区二区三区在线 | 日韩欧美在线一区 | 精品美女在线观看 | 亚洲精品乱码久久久久久9色 | 精品蜜桃一区二区三区 | 操夜夜| av在线亚洲天堂 | 国产精品久久久久久久久免费相片 | 激情五月婷婷综合 | 福利精品在线观看 | 日韩视频精品 | 亚洲三区在线 | 亚洲天堂av网 | 日韩在线不卡视频 | 午夜久久| 九色av | 91看片免费版 | 久久亚洲一区 | 欧产日产国产精品视频 | www.youjizz.com日韩 | hitomi一区二区三区精品 | 美女啪啪国产 | 欧美视频在线看 | 五月婷婷婷 | 91高清视频| va在线 | 日韩欧美在线一区 | 中文字幕亚洲视频 | 99免费视频| 一区二区三区免费在线观看 | 欧美日韩一区二区三区视频 | 久久精品亚洲精品 | 久久国产精品一区二区三区 | 91精品国产91久久久久久吃药 | 色婷婷久久久亚洲一区二区三区 | 久久成人一区 | 中文字幕黄色大片 | 成人夜晚看av | 精品国产乱码一区二区三 |