All pastes #441127 Raw Edit

Stuff

public php v1 · immutable
·published 2007-04-15 14:49 UTC
rendered paste body
public function getNeighbours($limit = 10, $radius = 10, $culture = null){      if($culture === null)  {    $culture = sfContext::getInstance()->getUser()->getCulture();  }      $lat = $this->getLat();  $lon = $this->getLon();   $query = new Doctrine_Query();       $locations =  $query->select("l.*, SUM(((ACOS(SIN(($lat*PI()/180)) * SIN((lat*pi()/180)) + COS(($lat*PI()/180)) * COS((lat*PI()/180)) * COS((($lon - lon)*PI()/180))))*180/PI())*60*1.1515) distance")            ->from('Location l , Location.LocationI18n i18n')  ->limit($limit)   // not current location  ->where('l.id != ? AND i18n.culture = ?', array($this->getId(), $culture))  ->having('distance < ?', $radius)  ->execute();            return $locations;        }