Should probably use the provided interface, through `EntityFieldQuery`. An example of its use: https://drupal.org/comment/3582106#comment-3582106 (the array of conditions is deprecated)