0
votes

I am attempting to query a custom content type called players (machine name) in a Drupal 7 module and it seemed to be working fine up until an hour ago. Nothing has changed on my side but now the 'Select' works, when I remove all the conditions, but when I add a fieldCondition I am getting empty results.

Here is my query:

$query = new EntityFieldQuery;
$query->entityCondition('entity_type', 'node')
  ->entityCondition('bundle', 'players')
  ->fieldCondition('field_email_address', 'value', $email_address)
  ->fieldCondition('field_password', 'value', $password)
  ->range(0, 1);

$results = $query->execute();

I have verified and reverified the bundle name, each machine name for the fields, and the values being passed in, but when I dump and die the query results, they come up empty.

Any ideas? Thanks!

1
this missing $query->execute(); , normal ? drupal.org/docs/7/creating-custom-modules/howtos/… - Fky
I have that just didn't add it to the post, but edited it to include it. - Wally Kolcz
did you dump values $email_address and $password ? if you make sql request with couple values you have results ? - Fky
It seems like a permission issue. When I am logged in as admin it works, when I am not, I cannot added the fieldConditions to the query. Any Ideas? - Wally Kolcz

1 Answers

3
votes

Ok, for some stupid reason you can query a whole database as an unauthenticated user but not with a where clause so you need to add ->addMetaData('account', user_load(1)) before the ->range(0,1). Hope this helps someone else.