【问题标题】:How to do OR in Laravel [duplicate]如何在 Laravel 中做 OR [重复]
【发布时间】:2019-02-19 04:25:56
【问题描述】:

我该怎么做

"SELECT * FROM table WHERE quote_id = ".$id." AND status = 7 OR status = 8"

使用 Laravel 查询。

到目前为止,我尝试做的是:

Test::where("quote_id", $id)->whereRaw("booking_status_id = 7 OR booking_status_id = 8")->get();

【问题讨论】:

  • Test::where("quote_id", $id)->->whereIn('booking_status_id', [7,8])->get();

标签: php laravel


【解决方案1】:

试试这个

Test::where("quote_id", $id)
 ->where(function($query) {
 $query->where('booking_status_id',7)
 ->orWhere('booking_status_id',8);
 })
->get(); 

【讨论】:

    猜你喜欢
    • 2020-05-05
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-05-24
    • 1970-01-01
    • 1970-01-01
    • 2020-04-15
    相关资源
    最近更新 更多