I have a very simple node type set up in drupal, see it here

And I'm trying to get the node id based on the email field (the email is unique to each node, just like the nid). My query looks like this:

$query  -> entityCondition('entity_type', 'node')
-> entityCondition('bundle', 'mail_entry')
-> fieldCondition('field_email', 'value', $email);

But drupal is complaining with:

"PDOException: SQLSTATE[42S22]: Column not found: 1054 Unknown column 'field_data_field_email0.field_email_value'"

I don't really understand what's wrong.


At a guess you're using the Email Field module to provide that particular field?

If so, the column name is email, not value, so your code should be:

$query->entityCondition('entity_type', 'node')
  ->entityCondition('bundle', 'mail_entry')
  ->fieldCondition('field_email', 'email', $email);
  • Thanks, I worked this out not too long ago. This works perfectly. Jul 31 '12 at 1:02
  • It seems this Exeption is generally thrown if the column parameter of the fieldCondition() method is wrong.
    – kask
    Jun 24 '14 at 12:02

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.