2016-11-29 138 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();