gpt4 book ai didi

Laravel Eloquent : multiple where() in the same column not working

转载 作者:行者123 更新时间:2023-12-02 21:19:27 33 4
gpt4 key购买 nike

在我的数据库中,我有“发布”列,其值为"new"、“待处理”、“正在运行”和“已暂停”。我想同时查询“待处理”和“正在运行”。我使用此代码,但它不起作用。

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

我需要帮助!

最佳答案

两个选项,但 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();

关于Laravel Eloquent : multiple where() in the same column not working,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40856396/

33 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com