In my Database, I have column 'publish' which values are 'new', 'pending', 'running' and 'paused'. I want to make a query for 'pending' and 'running' at the same time. I use this Code but it's not working.
$q_editpost = Menu::select('id', 'bcrumb', 'heading', 'content_id', 'content_type')
->where('publish', 'pending')
->where('publish', 'running')
->get();
I need help!
Two options, but the whereIn should be faster.
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();
Use whereIn for many where clouse.
$q_editpost = Menu::select('id', 'bcrumb', 'heading', 'content_id', 'content_type')
->whereIn('publish', ['pending', 'running'])
->get();
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With