2
votes

I use Drupal 7. This code:

$query = new EntityFieldQuery();
$resFirstName = $query->entityCondition('entity_type', 'node')
            ->entityCondition('bundle', 'user')
            ->fieldCondition('field_user_first_name', 'value', $str, 'RLIKE')
            ->range(0, 15)
            ->addTag('node_access')
            ->execute();

when site's user isn't Admin throws the following error: "PDOException: SQLSTATE[42S22]: Column not found: 1054 Unknown column 'field_data_field_user_first_name0.nid' in 'where clause': SELECT field_data_field_user_first_name0.entity_type AS entity_type, ..." If I remove ->fieldCondition('field_user_first_name', 'value', $str, 'RLIKE') or ->addTag('node_access') - no error.

Thanks

2

2 Answers

0
votes

I had a somewhat similar case. I was able to solve it modifying the fieldCondition like this while retaining all other conditions and parameters:

  ->fieldCondition('field_user', 'first_name', $str, 'RLIKE')
0
votes

I ran into a similar issue. I has node_access tag added to a query, I could not remove it since other modules relied on it to influence site queries globally. I had to add a fieldCondition, so in my case the solution was $query->addMetadata('account', user_load(1));

https://www.drupal.org/node/997394#comment-5096664