Symfony Creof FUNCTION mydbname.distance 不存在



我正在尝试使用CREOF束及其距离函数。当我执行以下代码时,我会得到以下例外:

public function getMapDecorator(array $requestInformation, $type) : MapDecorator {
        $queryBuilder = $this->entityManager->getRepository('AppBundle:Provider')->createQueryBuilder('provider');
    $point = new Point(0,0);
    $point->setLongitude($requestInformation["currentLongitude"]);
    $point->setLatitude($requestInformation["currentLatitude"]);
    // build the query
    $queryBuilder
        ->select('provider, DISTANCE(:point, provider.coordinates) AS HIDDEN distance')
        ->having('distance <= :radius')
        ->where("provider.type = :type")
        ->setParameter('type', $type)
        ->setParameter('radius', 10)
        ->setParameter('point', $point)
        ->orderBy('distance')
    ;
    $providers = $queryBuilder->getQuery()->getResult();
    return null;
}

执行此功能时,这是我得到的错误

"执行'选择a0_.id作为id_0, a0_.type为type_1,asbinary(a0_.coordinates)as coordinates_2, 距离(?,a0_.coordinates)为sclr_3,a0_.path_id as path_id_4, a0_.coordion_id as coortion_id_5来自提供商a0_ whene a0_.type =?具有sclr_3&lt; =?sclr_3 asc'订购params [{}," professional ",10]: n n nsqlstate [42000]:语法错误或访问 违规:1305功能mydbname.distance不存在"

我想知道为什么要遇到此错误,我可以看到调试此文件被称为:CrEOFSpatialORMQueryASTFunctionsMySqlDistance

我在配置中也有以下内容:

orm:
    auto_generate_proxy_classes: '%kernel.debug%'
    naming_strategy: doctrine.orm.naming_strategy.underscore
    auto_mapping: true
    dql:
        numeric_functions:
            # for mysql
            area:                   CrEOFSpatialORMQueryASTFunctionsMySqlArea
            asbinary:               CrEOFSpatialORMQueryASTFunctionsMySqlAsBinary
            astext:                 CrEOFSpatialORMQueryASTFunctionsMySqlAsText
            buffer:                 CrEOFSpatialORMQueryASTFunctionsMySqlBuffer
            centroid:               CrEOFSpatialORMQueryASTFunctionsMySqlCentroid
            contains:               CrEOFSpatialORMQueryASTFunctionsMySqlContains
            crosses:                CrEOFSpatialORMQueryASTFunctionsMySqlCrosses
            dimension:              CrEOFSpatialORMQueryASTFunctionsMySqlDimension
            distance:               CrEOFSpatialORMQueryASTFunctionsMySqlDistance
            disjoint:               CrEOFSpatialORMQueryASTFunctionsMySqlDisjoint
            distancefrommultyLine:  CrEOFSpatialORMQueryASTFunctionsMySqlDistanceFromMultyLine
            endpoint:               CrEOFSpatialORMQueryASTFunctionsMySqlEndPoint
            envelope:               CrEOFSpatialORMQueryASTFunctionsMySqlEnvelope
            equals:                 CrEOFSpatialORMQueryASTFunctionsMySqlEquals
            exteriorring:           CrEOFSpatialORMQueryASTFunctionsMySqlExteriorRing
            geodistpt:              CrEOFSpatialORMQueryASTFunctionsMySqlGeodistPt
            geometrytype:           CrEOFSpatialORMQueryASTFunctionsMySqlGeometryType
            geomfromtext:           CrEOFSpatialORMQueryASTFunctionsMySqlGeomFromText
            glength:                CrEOFSpatialORMQueryASTFunctionsMySqlGLength
            interiorringn:          CrEOFSpatialORMQueryASTFunctionsMySqlInteriorRingN
            intersects:             CrEOFSpatialORMQueryASTFunctionsMySqlIntersects
            isclosed:               CrEOFSpatialORMQueryASTFunctionsMySqlIsClosed
            isempty:                CrEOFSpatialORMQueryASTFunctionsMySqlIsEmpty
            issimple:               CrEOFSpatialORMQueryASTFunctionsMySqlIsSimple
            linestringfromwkb:      CrEOFSpatialORMQueryASTFunctionsMySqlLineStringFromWKB
            linestring:             CrEOFSpatialORMQueryASTFunctionsMySqlLineString
            mbrcontains:            CrEOFSpatialORMQueryASTFunctionsMySqlMBRContains
            mbrdisjoint:            CrEOFSpatialORMQueryASTFunctionsMySqlMBRDisjoint
            mbrequal:               CrEOFSpatialORMQueryASTFunctionsMySqlMBREqual
            mbrintersects:          CrEOFSpatialORMQueryASTFunctionsMySqlMBRIntersects
            mbroverlaps:            CrEOFSpatialORMQueryASTFunctionsMySqlMBROverlaps
            mbrtouches:             CrEOFSpatialORMQueryASTFunctionsMySqlMBRTouches
            mbrwithin:              CrEOFSpatialORMQueryASTFunctionsMySqlMBRWithin
            numinteriorrings:       CrEOFSpatialORMQueryASTFunctionsMySqlNumInteriorRings
            numpoints:              CrEOFSpatialORMQueryASTFunctionsMySqlNumPoints
            overlaps:               CrEOFSpatialORMQueryASTFunctionsMySqlOverlaps
            pointfromwkb:           CrEOFSpatialORMQueryASTFunctionsMySqlPointFromWKB
            pointn:                 CrEOFSpatialORMQueryASTFunctionsMySqlPointN
            point:                  CrEOFSpatialORMQueryASTFunctionsMySqlPoint
            srid:                   CrEOFSpatialORMQueryASTFunctionsMySqlSRID
            startpoint:             CrEOFSpatialORMQueryASTFunctionsMySqlStartPoint
            st_buffer:              CrEOFSpatialORMQueryASTFunctionsMySqlSTBuffer
            st_contains:            CrEOFSpatialORMQueryASTFunctionsMySqlSTContains
            st_crosses:             CrEOFSpatialORMQueryASTFunctionsMySqlSTCrosses
            st_disjoint:            CrEOFSpatialORMQueryASTFunctionsMySqlSTDisjoint
            st_equals:              CrEOFSpatialORMQueryASTFunctionsMySqlSTEquals
            st_intersects:          CrEOFSpatialORMQueryASTFunctionsMySqlSTIntersects
            st_overlaps:            CrEOFSpatialORMQueryASTFunctionsMySqlSTOverlaps
            st_touches:             CrEOFSpatialORMQueryASTFunctionsMySqlSTTouches
            st_within:              CrEOFSpatialORMQueryASTFunctionsMySqlSTWithin
            touches:                CrEOFSpatialORMQueryASTFunctionsMySqlTouches
            within:                 CrEOFSpatialORMQueryASTFunctionsMySqlWithin
            x:                      CrEOFSpatialORMQueryASTFunctionsMySqlX
            y:                      CrEOFSpatialORMQueryASTFunctionsMySqlY

OK找到了问题。MySQL弃用了距离功能,以支持ST_DISTANCE。这个捆绑包应该更新,但是暂时,我在捆绑包中创建了以下类:

namespace AppBundleORM;
use CrEOFSpatialORMQueryASTFunctionsAbstractSpatialDQLFunction;
/**
 * Distance DQL function
 *
 * @author  luca capra <luca.capra@create-net.org>
 * @license http://dlambert.mit-license.org MIT
 */
class STDistance extends AbstractSpatialDQLFunction {
    protected $platforms = array('mysql');
    protected $functionName = 'ST_Distance';
    protected $minGeomExpr = 2;
    protected $maxGeomExpr = 2;
}

我在配置中添加了:

st_distance:            AppBundleORMSTDistance

我现在使用ST_Distance代替Distance

相关内容

  • 没有找到相关文章

最新更新