2017-11-28 16 views
0

私はCreofバンドルとそのDistance関数を使用しようとしています。私は、次のコードを実行すると、私は次の例外を取得:ID_0 AS a0_.id SELECT」実行中にこれを実行すると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; 
} 

、これは」私は

を取得するとエラーになり、例外が発生し、 TYPE_1 AS a0_.type coordinates_2、sclr_3 AS 距離(?, a0_.coordinates)AS、AsBinary(a0_.coordinates)は、 は、プロバイダからAS coordinate_id_5 a0_.coordinate_id、path_id_4 AS a0_.path_id a0_ WHERE a0_.type =? '{}}、\ "professional \"という文字列を持つsclr_3 < =?ORDER BY sclr_3 ASC' 10]:\ nは\ nSQLSTATE [42000]:構文エラーまたはアクセス 違反:1305 FUNCTIONの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

OK]をクリックして、問題を発見しました。 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を使用します

関連する問題