[英]doctrine querybuilder syntax error expected =, <, <=, <>, >, >=, !=, got end of string
Having following error:出现以下错误:
"[Syntax Error] line 0, col -1: Error: Expected =, <, <=, <>, >, >=, !=, got end of string." “[语法错误] 第 0 行,第 -1 行:错误:预期 =、<、<=、<>、>、>=、!=,已结束字符串。”
building this query with doctrine querybuiler :使用学说 querybuiler 构建此查询:
SELECT *
FROM area
WHERE ST_Contains(polygon, ST_GeomFromText('POINT(13.405584 52.510621)', 1));
(Sf4 and Doctrine 2.6) (Sf4 和教义 2.6)
Orm config:奥姆配置:
orm:
dql:
numeric_functions:
ST_Contains: CrEOF\Spatial\ORM\Query\AST\Functions\MySql\STContains
ST_GeomFromText: App\Infrastructure\Persistence\Doctrine\STGeomFromText
POINT: CrEOF\Spatial\ORM\Query\AST\Functions\MySql\Point
STGeoFromText Class: STGeoFromText 类:
use CrEOF\Spatial\ORM\Query\AST\Functions\AbstractSpatialDQLFunction;
class STGeomFromText extends AbstractSpatialDQLFunction
{
protected $platforms = array('mysql');
protected $functionName = 'ST_GeomFromText';
protected $minGeomExpr = 1;
protected $maxGeomExpr = 2;
}
Construction of the query:查询的构建:
use CrEOF\Spatial\PHP\Types\Geometry\Point;
$lon = 13.405584;
$lat = 52.510621;
$qb = $this->getEntityManager()->createQueryBuilder();
$qb->select('a.name')
->from(Area::class, 'a')
->where("ST_Contains(a.polygon, ST_GeomFromText(':point', 1))")
->setParameter('point', new Point($lon, $lat), 'point');
$result = $query->getResult();
same error with:同样的错误:
->where("ST_Contains(a.polygon, ST_GeomFromText(:point, 1))")
notice no presence of symbol ' wrapping the :point parameter.注意没有符号 ' 包裹 :point 参数。
The error comes from Doctrine/ORM/Query/Parser.php , which tries to parse and validate the query build.错误来自Doctrine/ORM/Query/Parser.php ,它试图解析和验证查询构建。
The issue is caused by the parser not "understanding" that ST_Contains returns a boolean value and expects a comparisor operator which could one of the following " =, <, <=, <>, >, >=, != ".该问题是由解析器不“理解” ST_Contains返回布尔值并期望比较运算符引起的,该比较运算符可以是以下“ =、<、<=、<>、>、>=、!= ”之一。
To overcome this, add = true
to your condition:为了克服这个问题,请在您的条件中添加= true
:
->where("ST_Contains(a.polygon, ST_GeomFromText(:point, 1)) = true")
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.