【发布时间】:2017-11-28 16:00:09
【问题描述】:
我正在尝试使用 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;
}
执行此操作时,这是我得到的错误
"执行'SELECT a0_.id AS id_0时发生异常, a0_.type AS type_1, AsBinary(a0_.coordinates) AS coordinates_2, 距离(?, a0_.coordinates) AS sclr_3, a0_.path_id AS path_id_4, a0_.coordinate_id AS coordinate_id_5 FROM provider a0_ WHERE a0_.type = ?有 sclr_3
我想知道为什么会出现这个错误,我可以看到调试该文件正在被调用: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
【问题讨论】:
标签: php symfony doctrine-orm doctrine-query doctrine-extensions