2017-11-28 16 views
0

Creof 번들과 Distance 함수를 사용하려고합니다. I는 다음과 같은 코드를 실행할 때, I는 다음과 같은 예외가 :Symfony Creof FUNCTION mydbname.distance가 존재하지 않습니다.

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; 
} 

이 실행이이 에러 난 ID_0 AS a0_.id SELECT "실행 중

는"예외가 발생 얻을 TYPE_1 AS a0_.type coordinates_2, sclr_3 AS 거리 (? a0_.coordinates) AS, AsBinary (a0_.coordinates)는, 제공자 FROM coordinate_id_5 a0_.coordinate_id AS, AS path_id_4 a0_.path_id a0_ WHERE a0_.type =? 'param [{}, \ "professional \"로 sclr_3 < =? ORDER BY sclr_3 ASC' 10] : \ n \ nSQLSTATE [42000] : 구문 오류 또는 액세스 가 위반 : 1305 기능의 mydbname.Distance 나는이 오류를 받고 있어요 왜 내가 디버깅을 볼 수있다 "궁금

존재하지 않는이 파일 호출되는 : CrEOF\Spatial\ORM\Query\AST\Functions\MySql\Distance

나는 또한 내 구성은 다음과 같습니다

orm: 
    auto_generate_proxy_classes: '%kernel.debug%' 
    naming_strategy: doctrine.orm.naming_strategy.underscore 
    auto_mapping: true 
    dql: 
     numeric_functions: 
      # for mysql 
      area:     CrEOF\Spatial\ORM\Query\AST\Functions\MySql\Area 
      asbinary:    CrEOF\Spatial\ORM\Query\AST\Functions\MySql\AsBinary 
      astext:     CrEOF\Spatial\ORM\Query\AST\Functions\MySql\AsText 
      buffer:     CrEOF\Spatial\ORM\Query\AST\Functions\MySql\Buffer 
      centroid:    CrEOF\Spatial\ORM\Query\AST\Functions\MySql\Centroid 
      contains:    CrEOF\Spatial\ORM\Query\AST\Functions\MySql\Contains 
      crosses:    CrEOF\Spatial\ORM\Query\AST\Functions\MySql\Crosses 
      dimension:    CrEOF\Spatial\ORM\Query\AST\Functions\MySql\Dimension 
      distance:    CrEOF\Spatial\ORM\Query\AST\Functions\MySql\Distance 
      disjoint:    CrEOF\Spatial\ORM\Query\AST\Functions\MySql\Disjoint 
      distancefrommultyLine: CrEOF\Spatial\ORM\Query\AST\Functions\MySql\DistanceFromMultyLine 
      endpoint:    CrEOF\Spatial\ORM\Query\AST\Functions\MySql\EndPoint 
      envelope:    CrEOF\Spatial\ORM\Query\AST\Functions\MySql\Envelope 
      equals:     CrEOF\Spatial\ORM\Query\AST\Functions\MySql\Equals 
      exteriorring:   CrEOF\Spatial\ORM\Query\AST\Functions\MySql\ExteriorRing 
      geodistpt:    CrEOF\Spatial\ORM\Query\AST\Functions\MySql\GeodistPt 
      geometrytype:   CrEOF\Spatial\ORM\Query\AST\Functions\MySql\GeometryType 
      geomfromtext:   CrEOF\Spatial\ORM\Query\AST\Functions\MySql\GeomFromText 
      glength:    CrEOF\Spatial\ORM\Query\AST\Functions\MySql\GLength 
      interiorringn:   CrEOF\Spatial\ORM\Query\AST\Functions\MySql\InteriorRingN 
      intersects:    CrEOF\Spatial\ORM\Query\AST\Functions\MySql\Intersects 
      isclosed:    CrEOF\Spatial\ORM\Query\AST\Functions\MySql\IsClosed 
      isempty:    CrEOF\Spatial\ORM\Query\AST\Functions\MySql\IsEmpty 
      issimple:    CrEOF\Spatial\ORM\Query\AST\Functions\MySql\IsSimple 
      linestringfromwkb:  CrEOF\Spatial\ORM\Query\AST\Functions\MySql\LineStringFromWKB 
      linestring:    CrEOF\Spatial\ORM\Query\AST\Functions\MySql\LineString 
      mbrcontains:   CrEOF\Spatial\ORM\Query\AST\Functions\MySql\MBRContains 
      mbrdisjoint:   CrEOF\Spatial\ORM\Query\AST\Functions\MySql\MBRDisjoint 
      mbrequal:    CrEOF\Spatial\ORM\Query\AST\Functions\MySql\MBREqual 
      mbrintersects:   CrEOF\Spatial\ORM\Query\AST\Functions\MySql\MBRIntersects 
      mbroverlaps:   CrEOF\Spatial\ORM\Query\AST\Functions\MySql\MBROverlaps 
      mbrtouches:    CrEOF\Spatial\ORM\Query\AST\Functions\MySql\MBRTouches 
      mbrwithin:    CrEOF\Spatial\ORM\Query\AST\Functions\MySql\MBRWithin 
      numinteriorrings:  CrEOF\Spatial\ORM\Query\AST\Functions\MySql\NumInteriorRings 
      numpoints:    CrEOF\Spatial\ORM\Query\AST\Functions\MySql\NumPoints 
      overlaps:    CrEOF\Spatial\ORM\Query\AST\Functions\MySql\Overlaps 
      pointfromwkb:   CrEOF\Spatial\ORM\Query\AST\Functions\MySql\PointFromWKB 
      pointn:     CrEOF\Spatial\ORM\Query\AST\Functions\MySql\PointN 
      point:     CrEOF\Spatial\ORM\Query\AST\Functions\MySql\Point 
      srid:     CrEOF\Spatial\ORM\Query\AST\Functions\MySql\SRID 
      startpoint:    CrEOF\Spatial\ORM\Query\AST\Functions\MySql\StartPoint 
      st_buffer:    CrEOF\Spatial\ORM\Query\AST\Functions\MySql\STBuffer 
      st_contains:   CrEOF\Spatial\ORM\Query\AST\Functions\MySql\STContains 
      st_crosses:    CrEOF\Spatial\ORM\Query\AST\Functions\MySql\STCrosses 
      st_disjoint:   CrEOF\Spatial\ORM\Query\AST\Functions\MySql\STDisjoint 
      st_equals:    CrEOF\Spatial\ORM\Query\AST\Functions\MySql\STEquals 
      st_intersects:   CrEOF\Spatial\ORM\Query\AST\Functions\MySql\STIntersects 
      st_overlaps:   CrEOF\Spatial\ORM\Query\AST\Functions\MySql\STOverlaps 
      st_touches:    CrEOF\Spatial\ORM\Query\AST\Functions\MySql\STTouches 
      st_within:    CrEOF\Spatial\ORM\Query\AST\Functions\MySql\STWithin 
      touches:    CrEOF\Spatial\ORM\Query\AST\Functions\MySql\Touches 
      within:     CrEOF\Spatial\ORM\Query\AST\Functions\MySql\Within 
      x:      CrEOF\Spatial\ORM\Query\AST\Functions\MySql\X 
      y:      CrEOF\Spatial\ORM\Query\AST\Functions\MySql\Y 

답변

0

확인 문제를 발견. MySQL은 ST_Distance를 위해 Distance 함수를 사용하지 않았습니다. 이 번들은 업데이트해야하지만, 당분간, 나는 나의 번들에 다음과 같은 클래스를 만들었 :

namespace AppBundle\ORM; 

use CrEOF\Spatial\ORM\Query\AST\Functions\AbstractSpatialDQLFunction; 

/** 
* Distance DQL function 
* 
* @author luca capra <[email protected]> 
* @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:   AppBundle\ORM\STDistance 

내가 지금 ST_Distance 대신 Distance를 사용