2

Drupal dynamic queries have 2 conditional clauses called having and havingCondition.

The documentation states "The Having clause behaves identically to the WHERE clause, except that it uses methods havingCondition() and having() instead of condition() and where()."

Other than this I can't find any mention of either clauses anywhere (including in the examples module), or any examples of their use.

What is the difference between the 2 functions?

1 Answer 1

1

I figured it out though trail and error.

Example of a having clause:

$query->having('user_count > 0');

Example of a havingCondition clause:

$query->havingCondition('user_count', 0, '>');

Essentially you can pass the alias, value and operator as separate arguments into havingCondition, but have to pass them all as one string into having.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.