1

I have a field called field_url which is of type link. I want to query and fetch all those nodes which have field_url value like eg. www.google.com. I tried using the below code:

$query = new EntityFieldQuery();
$query->entityCondition('entity_type', 'node')
  ->entityCondition('bundle', 'websites')
  ->fieldCondition('field_url','value','%google%','like');
  $result = $query->execute();

I get database error with this. I saw the values stored in field_data_field_url table and they look like serialized. What is the correct way of doing this?

  • 1
    There's no way to filter by serialised PHP properties through a DB query. If the data you need is in a serialised string, you'll either need to come up with a LIKE/REGEXP expression that reliably matches what you're looking for, or load all row in PHP and extract the relevant rows after deserialising the data – Clive Aug 14 at 10:08

Your Answer

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

Browse other questions tagged or ask your own question.