0
我需要進行兩個連接,但與許多條件語句那裏,我有這個多加入Laravel
$matchThese = [ 'suspended' => 0, 'status' => 1, 'approved' => 1 ];
$matchOther = [ 'status' => 1, 'approved' => 0 ];
$deals = ListsDeals::where($matchThese)->where('stock', '>', 0)->orwhere($matchOther)->whereDate('end_date', '>', date('Y-m-d'))->limit(4)->offset(0)->orderBy('start_date')->get();
$deals_lists = DB::table('deals')
->join('list_has_deals', 'deals.id', '=', 'list_has_deals.deal_id' )
->join('lists', 'list_has_deals.list_id', '=', 'lists.id')
->paginate(10);
我需要兩個瓦爾一個唯一的查詢,選擇具有「何在」的所有交易在第一VAR並且隨後做出連接,問候。
我添加一些更多的代碼,這給我的錯誤 SQLSTATE [23000]:完整性約束衝突:在where子句是模糊的1052列「暫停」( SQL:select count(*)作爲來自'deals'的聚合內部連接'list_has_deals' on'deal'.'id' ='list_has_deals'.'deal_id'內部連接'列表'list_has_deals'''list_id' ='列表''.''其中('suspe' = 0和'status' = 1且'approved' = 1)和'stock'> 0或('status' = 1且'approved' = 0)和date('end_date ')> 2017-08-14) –
當你在查詢中進行連接時,你需要告訴Eloquent在哪個表中進行選擇點語法:例如 - > where('table.suspended','=','something') –
工作非常好,謝謝:D –