Reputation: 136
I'd like to make a MySQL query with doctrine2 QueryBuilder (Symfony 3.4 app) with a NOT BETWEEN
statment.
The doctrine provide a ->expr()->between(..)
but not ->expr()->notBetween(..)
Is there a way to negate the between with the query builder.
I don't want to use a native or a DQL query if possible.
Note: I think a possible solution is to use ->expr()->lt(..)
and/or ->expr()->gt(..)
but I want to know if notBetween
is possible.
Thanks
Expected:
A NOT BETWEEN
SQL statement with Doctrine2 QueryBuilder
Upvotes: 1
Views: 676
Reputation: 136
After some attempts, I found a suitable solution for me:
The QueryBuilder provide a ->expr()->not(...)
, so in this case this is possible:
$qb->exp()->not($qb->between('field', 'from', 'to')
SQL result:
NOT (BETWEEN field from AND TO)
Upvotes: 1