在我的数据库中,我有"发布"列,其值为"新","待定","正在运行"和"已暂停".我想同时查询"待定"和"正在运行".我使用此代码,但它不起作用.
$q_editpost = Menu::select('id', 'bcrumb', 'heading', 'content_id', 'content_type')
->where('publish', 'pending')
->where('publish', 'running')
->get();
Run Code Online (Sandbox Code Playgroud)
我需要帮助!
两个选项,但whereIn应该更快.
1)
$q_editpost = Menu::select('id', 'bcrumb', 'heading', 'content_id', 'content_type')
->whereIn('publish', ['pending', 'running'])
->get();
Run Code Online (Sandbox Code Playgroud)
2)
$q_editpost = Menu::select('id', 'bcrumb', 'heading', 'content_id', 'content_type')
->where('publish', 'pending')
->orWhere('publish', 'running')
->get();
Run Code Online (Sandbox Code Playgroud)
对于许多 where 循环使用 whereIn。
$q_editpost = Menu::select('id', 'bcrumb', 'heading', 'content_id', 'content_type')
->whereIn('publish', ['pending', 'running'])
->get();
Run Code Online (Sandbox Code Playgroud)
归档时间: |
|
查看次数: |
3363 次 |
最近记录: |