I have created a custom entity, called 'point'.
I'm able to get all of the entities in the db, with this:
$query = new EntityFieldQuery();
$query->entityCondition('entity_type', 'point')
->entityCondition('bundle', 'point');
$result = $query->execute();
But when I add a fieldCondition, to make sure I only get the one single entity I want, I'll get an empty array back.
It looks like this:
$query = new EntityFieldQuery();
$query->entityCondition('entity_type', 'point')
->entityCondition('bundle', 'point')
->fieldCondition('field_point_unique_number', 'value', $unique_number, '=');
$result = $query->execute();
Where $unique_number is a textstring. And it's not a typo in the textstring. In the db the field 'field_point_unique_number' is a varchar, but only contains numbers.
Why does the fieldCondition return nothing?
$unique_number
is what you expect, and the same for the data in the database (make sure there are no leading/trailing spaces, etc) See drupal.stackexchange.com/questions/36542/debug-entityfieldquery for suggestions on seeing the generated query string so you can check for anomalies there too – Clive♦ Apr 26 '17 at 10:17