2017-08-30 118 views
2

其實我的查詢是:Laravel - 如何在where子句中編寫多個條件?

SELECT * FROM company WHERE status<>$status AND type=$b1 AND type=$b2

如何laravel這種轉換?

我這樣做是在laravel,但它不工作:

$data['Company'] = DB::table('company')->where([["status","<>",$status], ["type","=",$b1],["type","=",$b2]])->get();

請幫幫我!

+0

這種嘗試:'$數據[ '公司'] = DB ::表(」 (''',$ b2) - > get();' –

回答

0
$data['company'] = DB::table('company')->where('status',$status)->where('type',$b1)->where('type',$b2)->get(); 
+0

使用('''') - >其中('status','<>',$ status) - > where('type',$ b1) - > D B;在你的控制器中 –

0

您應該使用其中1個工況法

$data['Company'] = DB::table('company')->where('status','<>',$status)->where('t‌​ype',$b1)->where('ty‌​pe',$b2)->get(); 
0

試試這個:

\App\Company::where('status','!=',$status)->where('type',$b1)->where('type',$b2)->get();