Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
By phoehne on
Hi,
Is it possible to negate a condition of a database-query
I know its no problem to nest conditions via db_or|and|xor. But is it possible to negate such a condition on an arbitrary position.
For example sth like:
$condition = db_not()->condition('b.date' , $date, '=');
I know i can change the operator to "!=". But there are cases where such a method would be useful.
Greetings Peter
Comments
As far as I know there isn't
As far as I know there isn't a way to do this, and there might be good reasons. For instance, how would it handle comparisons to NULL values? It is probably better to explicitly state the conditional operator, rather than hide what is really going on in a class.
--
Read more at iRolo.net