2016-11-29 7 views
4

私のデータベースでは、値が 'new'、 'pending'、 'running'、 'paused'のカラムがあります。 'pending'と 'running'のクエリを同時に作成したいと思います。私はこのコードを使用しますが、動作しません。Laravel 5.3 Eloquent:multiple where()は同じ列で動作しません

$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

つのオプションが、ここではより高速にする必要があります。

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(); 
関連する問題