src/FilterRules/Perimetersearch.php
protected function runSimpleQuery($idField, $tableName, $latitudeField, $longitudeField, $additionalWhere)
    {
        $distanceCalculation = HaversineSphericalDistance::getFormulaAsQueryPart(
            $this->latitude,
            $this->longitude,
            $this->connection->quoteIdentifier($latitudeField),
            $this->connection->quoteIdentifier($longitudeField),
            2
        );

        $builder = $this->connection->createQueryBuilder();
        $builder
            ->select($this->connection->quoteIdentifier($idField))
            ->from($tableName)
            ->where($builder->expr()->lte($distanceCalculation, ':distance'))
            ->orderBy($distanceCalculation)
            ->setParameter('distance', $this->dist);

        if ($additionalWhere) {
            foreach ($additionalWhere as $index => $where) {
                if (0 === $index) {
                    $builder->where($where);
                }

                $builder->andWhere($where);
            }

            $builder->andWhere($builder->expr()->lte($distanceCalculation, ':distance'));
        } else {
            $builder->where($builder->expr()->lte($distanceCalculation, ':distance'));
        }

        $statement = $builder->execute();
        if (!$statement->rowCount()) {
            return [];
        }

        return $statement->fetchAll(\PDO::FETCH_COLUMN);
    }
protected function runSimpleQuery($idField, $tableName, $latitudeField, $longitudeField, $additionalWhere)
    {
        $distanceCalculation = HaversineSphericalDistance::getFormulaAsQueryPart(
            $this->latitude,
            $this->longitude,
            $this->connection->quoteIdentifier($latitudeField),
            $this->connection->quoteIdentifier($longitudeField),
            2
        );

        $builder = $this->connection->createQueryBuilder();
        $builder
            ->select($this->connection->quoteIdentifier($idField))
            ->from($tableName)
            ->where($builder->expr()->lte($distanceCalculation, ':distance'))
            ->orderBy($distanceCalculation)
            ->setParameter('distance', $this->dist);

        if ($additionalWhere) {
            foreach ($additionalWhere as $index => $where) {
                if (0 === $index) {
                    $builder->where($where);
                }

                $builder->andWhere($where);
            }

            $builder->andWhere($builder->expr()->lte($distanceCalculation, ':distance'));
        } else {
            $builder->where($builder->expr()->lte($distanceCalculation, ':distance'));
        }

        $statement = $builder->execute();
        if (!$statement->rowCount()) {
            return [];
        }

        return $statement->fetchAll(\PDO::FETCH_COLUMN);
    }
protected function runSimpleQuery ( $ idField , $ tableName , $ latitudeField , $ longitudeField , $ additionalWhere ) { $ distanceCalculation = HaversineSphericalDistance :: getFormulaAsQueryPart ( $ this -> latitude , $ this -> longitude , $ this -> connection -> quoteIdentifier ( $ latitudeField ) , $ this -> connection -> quoteIdentifier ( $ longitudeField ) , 2 ) ; $ builder = $ this -> connection -> createQueryBuilder ( ) ; $ builder -> select ( $ this -> connection -> quoteIdentifier ( $ idField ) ) -> from ( $ tableName ) -> where ( $ builder -> expr ( ) -> lte ( $ distanceCalculation , ':distance' ) ) -> orderBy ( $ distanceCalculation ) -> setParameter ( 'distance' , $ this -> dist ) ; if ( $ additionalWhere ) { foreach ( $ additionalWhere as $ index => $ where ) { if ( 0 === $ index ) { $ builder -> where ( $ where ) ; } $ builder -> andWhere ( $ where ) ; } $ builder -> andWhere ( $ builder -> expr ( ) -> lte ( $ distanceCalculation , ':distance' ) ) ; } else { $ builder -> where ( $ builder -> expr ( ) -> lte ( $ distanceCalculation , ':distance' ) ) ; } $ statement = $ builder -> execute ( ) ; if ( ! $ statement -> rowCount ( ) ) { return [ ] ; } return $ statement -> fetchAll ( \ PDO :: FETCH_COLUMN ) ; }
Build the SQL and execute it.

@param string     $idField         Name of the id field.
@param string     $tableName       The name of the table.
@param string     $latitudeField   The name of the latitude field.
@param string     $longitudeField  The name of the longitude field.
@param array|null $additionalWhere A list with additional where information.

@return array A list with ID's or an empty array.
Build the SQL and execute it .