0

I want to use hook_query_alter to alter a query constructed by a module. This is the code I use:

function MYMODULE_query_alter($query) {
  if ($query->hasTag('agent')) {
    $query->fieldCondition('field_area', 'tid', 10, '=');
  }
}

The code above gives a 500 error: Call to undefined method SelectQuery::fieldCondition()

What is the proper way to add a field condition to the query?

  • fieldCondition() is a method from the EntityFieldQuery class, it's not part of a standard database query. – Clive Sep 13 '12 at 0:16
  • yes, it took me some time to realize this. However, the question remains. – Mike Sep 13 '12 at 0:22
0

This was solved using the $query->innerJoin()

0

To use condition in query simply use:

$query->condition('field_area', 'tid', 10, '=');

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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