簡體   English   中英

我在laravel查詢語言中遇到錯誤

[英]I am getting error in laravel query language

缺少Illuminate \\ Database \\ Connection :: table()的參數1

我在表函數中傳遞參數。 我在我正在使用的數據庫的每個功能上收到此錯誤。

當我創建模型的對象然后使用函數table()時它工作正常。

這是我正在使用的代碼。

return DB::table('crop_growth')
         ->leftJoin('farmer_details', 'crop_growth.farmer_id', '=', 'farmer_details.id')
         ->select('crop_growth.id', 'crop_growth.remind_after', 'crop_growth.reason', 'crop_growth.is_read', 'farmer_details.name', 'farmer_details.phone')
         ->where('crop_growth.emp_id', $empId)
         ->where('crop_growth.remind_after', '!=', null)
         ->orderBy('crop_growth.is_read', 'ASC')
         ->orderBy('crop_growth.remind_after', 'ASC')
         ->get();

您需要在查詢中添加表方法然后設置。

DB::connection('mysql / <or whatever mane you called it>')->table('crop_growth')-> rest of your query.

如果仍有錯誤,可以在表字段中設置數據庫。

table('<database>.crop_growth')

雖然我會首先設置一個測試選擇然后左邊的連接然后是實際的選擇,但這是可以的。

祝好運

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM