久久久久久久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 列的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學(xué)習(xí)吧!

問題描述

我收到這個奇怪的錯誤:

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 模型中調(diào)用鎖作用域.我有很多開關(guān)盒,其中之一是lock.我已經(jīng)在頂部運行了一半的查詢,所以我不必重復(fù)自己.我只是將它存儲在 $thread 變量中,以便我可以執(zhí)行諸如 $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 子句,而我只是將它繼續(xù)到我的范圍內(nèi).

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]); 應(yīng)該是 ->update(['locked' => 1]);

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

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

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

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

相關(guān)文檔推薦

Magento products by categories(按類別劃分的 Magento 產(chǎn)品)
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)
主站蜘蛛池模板: 欧美日韩中文在线 | 国产精品一区二区视频 | 国产一级一级 | 久久久久国产一区二区 | 国产成人av免费看 | 999在线精品 | 日韩精品 电影一区 亚洲 | 国产美女一区二区 | 久久久久久久一区二区 | 四虎成人免费电影 | 米奇狠狠鲁| 一道本视频 | 亚洲高清电影 | 91资源在线观看 | 国产一区二区在线免费 | 嫩草一区二区三区 | 日韩国产一区二区三区 | 亚洲三区在线 | 日韩中文在线观看 | 可以在线看的黄色网址 | 欧美日韩综合视频 | 搞av.com| 在线免费中文字幕 | 亚洲国产精品一区二区三区 | 国产精品久久久久久久7777 | 亚洲最大的成人网 | 亚洲精品乱码久久久久久久久久 | 亚洲精品欧美 | 久久久久久久香蕉 | 久久99精品国产 | 蜜桃视频在线观看免费视频网站www | 国产999精品久久久影片官网 | 在线观看www高清视频 | 成人亚洲性情网站www在线观看 | 精精国产xxxx视频在线播放 | 亚洲一在线| 成人性视频免费网站 | 三级免费av | 99久久婷婷国产综合精品电影 | 成人黄色三级毛片 | 在线看91|