0

I have an Entity Field Query that has fieldCondition for field_email

  ->fieldCondition('field_email', 'value', $email , '=');

I have verified that this is the name of the field and I have other entity queries that use this field correctly. However, in this example, Drupal is adding the digit 2 on to the field name as I understand the error returned.

$dup_query1 = new EntityFieldQuery(); 
$dup_query1->entityCondition('entity_type', 'node') ->entityCondition('bundle', 'fair_participant')
 ->fieldCondition('field_last_name', 'value', $last_name , '=')
 ->fieldCondition('field_first_name', 'value', $first_name , '=')
 ->fieldCondition('field_email', 'value', $email , '='); 

$fpmatch_fandl_email = $dup_query1->execute();

SQLSTATE[42S22]: Column not found: 1054 Unknown column 'field_data_field_email2.field_email_value' in 'where clause'

Any help is greatly appreciated.

Thanks, Josh

4
  • I believe that is an alias in the query
    – Kevin
    Jan 8, 2019 at 18:38
  • What is the full code of the Entity Field Query?
    – Kevin
    Jan 8, 2019 at 18:48
  • Here is the query. Thank you. ` $dup_query1 = new EntityFieldQuery(); $dup_query1->entityCondition('entity_type', 'node') ->entityCondition('bundle', 'fair_participant') ->fieldCondition('field_last_name', 'value', $last_name , '=') ->fieldCondition('field_first_name', 'value', $first_name , '=') ->fieldCondition('field_email', 'value', $email , '='); $fpmatch_fandl_email = $dup_query1->execute();`
    – Josh
    Jan 8, 2019 at 19:16
  • do you use email module ??
    – berramou
    Jan 8, 2019 at 22:58

1 Answer 1

1

If you use Email module, use email instead of value, because the module store the value in field_name_email not field_name_value like other field like text ... So you Query should be like:

$dup_query1 = new EntityFieldQuery();
$dup_query1->entityCondition('entity_type', 'node') 
    ->entityCondition('bundle', 'fair_participant')
    ->fieldCondition('field_last_name', 'value', $last_name , '=')
    ->fieldCondition('field_first_name', 'value', $first_name , '=')
    // use email not value.
    ->fieldCondition('field_email', 'email', $email , '=');

$fpmatch_fandl_email = $dup_query1->execute();

Your Answer

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

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