2016-11-29 54 views
4

在我的數據庫中,我有列'發佈'值'新','等待','運行'和'已暫停'。 我想同時查詢'正在等待'和'正在運行'。我使用此代碼,但它不起作用。Laravel 5.3雄辯:多個在同一列不工作()的地方

$q_editpost = Menu::select('id', 'bcrumb', 'heading', 'content_id', 'content_type') 
     ->where('publish', 'pending') 
     ->where('publish', 'running') 
     ->get(); 

我需要幫助!

回答

0

使用whereIn在很多地方clouse。

$q_editpost = Menu::select('id', 'bcrumb', 'heading', 'content_id', 'content_type') 
     ->whereIn('publish', ['pending', 'running']) 
     ->get(); 
3

兩個選項,但whereIn應該更快。

1)

$q_editpost = Menu::select('id', 'bcrumb', 'heading', 'content_id', 'content_type') 
     ->whereIn('publish', ['pending', 'running']) 
     ->get(); 

2)

$q_editpost = Menu::select('id', 'bcrumb', 'heading', 'content_id', 'content_type') 
     ->where('publish', 'pending') 
     ->orWhere('publish', 'running') 
     ->get();