Пример #1
0
 public static function loadWithinBorder(Polygon $border, $types, $exceptId = 0)
 {
     $res = db()->select()->all('poi')->col('latLng', 'poi')->op(AS_TEXT)->alias('latLngWKT')->col('border', 'poi')->op(AS_TEXT)->alias('borderWKT')->col('name', 'poiNear')->alias('nearName')->col('name', 'poiCountry')->alias('countryName')->col('name', 'poiType')->alias('subName')->from('poi')->leftJoin('poi')->alias('poiNear')->on('id', 'nearId')->leftJoin('poi')->alias('poiCountry')->on('id', 'countryId')->leftJoin('poi_type')->alias('poiType')->on('id', 'sub')->where("ST_Within(GeomFromText(POINT(`poi`.`lng`, `poi`.`lat`)), GeomFromText({$border->toWKT()}))")->andCond('sub', 'poi', IN, $types)->andCond('id', 'poi', NE, $exceptId)->exec();
     while ($o = $res->fetchObject()) {
         $pois[] = new POIModel($o);
     }
     return $pois;
 }