1

I'm very new to Drupal and I need to grab all nodes that have a certain word in them, for example I want to grab all nodes with the Word 'Hello' inside the body field. I need to use the EntityFieldQuery class too. I'm assuming I need to use the fieldCondition method but not sure how to set that up as there's not a lot of documentation...

Thanks Alex

1 Answer 1

1

I'm not sure I'd agree there's not a lot of documentation out there (there are tons, just search Google for EntityFieldQuery).

That said, something like:

$query = new EntityFieldQuery();
$query->entityCondition('entity_type', 'node')
  ->propertyCondition('type', 'some_type')
  ->fieldCondition('body', 'value', '%' . db_like($input_string) . '%', 'LIKE');

$results = $query->execute();

is probably what you're looking for

2
  • 1
    Thanks, I agree there's lots of documentation but not enough code examples.
    – user990717
    Mar 21, 2013 at 17:05
  • Good point actually, if it was clearer that EFQ wraps around a standard SelectQuery object it would probably be more obvious where to look for samples
    – Clive
    Mar 21, 2013 at 17:13

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.