Laravel /雄辩的地方不在 [英] Laravel / Eloquent WHERE NOT SUBQUERY

查看:92
本文介绍了Laravel /雄辩的地方不在的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我无法设置这样的负面条件:

I`m having trouble to setup a negative condition like such:

WHERE NOT( "last_day" "<=" $first_day OR "first_day" "<=" $last_day)

我的查询生成器看起来像这样atm:

My query builder looks like this atm:

$query = $query->where(function ($query) use ($first_day, $last_day) {
   $query->where('last_day', '<=', $first_day);
   $query->orWhere('first_day', '<=', $last_day);
});

我希望是这样的:

$query = $query->whereNot(function ($query) use ($first_day, $last_day) {
  $query->where('last_day', '<=', $first_day);
  $query->orWhere('first_day', '<=', $last_day);
});

要概述:我想要一个负的WHERE条件中的OR语句。如何实现这一点?

To recap: I want an OR statement inside a negative WHERE condition. How can I accomplish this?

来源: http://baodad.blogspot.nl/2014/06/date-range-overlap.html

推荐答案

根据这里找到的答案,恢复约束:雄辩MYSQL语句:WHERE NOT(A或B)

Went with reverting constraints according to answer found here: Eloquent MYSQL statement : WHERE NOT(A OR B)

$query = $query->where('last_day', '>', $first_day)->where('first_day', '>', $last_day);

这篇关于Laravel /雄辩的地方不在的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆