How do I write an entity field query that uses information like latitude and longitude from the location as fieldConditions?

Comments

dave reid’s picture

The 7.x-3.x doesn't look to provide actual Field API fields, so you aren't going to get any benefit using EntityFieldQuery and you should use a combination of EntityFieldQuery() to search across the non-location fields and narrow down the list of possible nids, and then a manual query with db_select() running the joins on the location tables you need. That might be your best bet.

cosmicdreams’s picture

Is there some magic that coverts a previously defined EntityFieldQuery into a SelectQuery ? I'm having trouble doing this:

<?php
$query = new EntityFieldQuery();
$query->entityCondition('entity_type', 'node')
    ->entityCondition('bundle', 'my_location');
$select = db_select($query, 's')->join('location', 'l', 's.lid =l.lid');
dave reid’s picture

Unfortunately not. You're maybe just best querying directly:

$query = db_select('node', 'n');
$query->join('location_instance', 'li', 'n.nid = li.nid');
$query->join('location', 'l', 'li.lid = l.lid');
$query->condition('n.type', 'my_location');
...
chx’s picture

class LocationEntityFieldQuery extends EntityFieldQuery {
    function finishQuery($select_query, $id_key = 'entity_id') {
    // oh hai $select_query! I can haz location filters added.
    }
}
legolasbo’s picture

Issue summary: View changes
Status: Active » Closed (outdated)

Closing support tickets that have been inactive for over a year to clean up the issue queue. Please reopen if this is still an issue.