久久久久久久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中文字幕 | 亚洲一卡二卡 | av手机在线看 | 一区二区三区四区免费在线观看 | 国产精品永久免费 | 蜜月aⅴ免费一区二区三区 99re在线视频 | 天天操人人干 | 中文字幕av色 | 久久久亚洲成人 | 亚洲在线| 欧美在线a | 日韩免费网站 | 中文字幕国产 | 国产精品成人在线 | 狠狠入ady亚洲精品经典电影 | 99精品电影| 一二三四在线视频观看社区 | h漫在线观看 | 成人亚洲精品久久久久软件 | 久久人体视频 | 二区三区av | 欧美激情一区二区 | www亚洲精品| 成人午夜网站 | 亚洲国产一区二区三区 | 日韩成人免费 | 伊人网伊人| 六月成人网| 亚洲视频欧美视频 | 自拍视频网站 | 玖玖久久 |