All pastes #452518 Raw Edit

Stuff

public text v1 · immutable
·published 2007-04-22 10:27 UTC
rendered paste body
$radius = 5;
$lat = $this->getLat();
$lon = $this->getLon();
    
$query = new Doctrine_Query();
    
$connection = sfDoctrine::connection();
$connection->setAttribute(Doctrine::ATTR_PORTABILITY, Doctrine::PORTABILITY_ALL ^ Doctrine::PORTABILITY_EXPR);
        
$locations =  $query->select("l.*, (((ACOS(SIN(($lat*PI()/180)) * SIN((l.lat*pi()/180)) + COS(($lat*PI()/180)) * COS((l.lat*PI()/180)) * COS((($lon - l.lon)*PI()/180))))*180/PI())*60*1.1515) distance")
                    ->from('Location l')
                    ->having("distance < $radius")
                    ->execute();