简体   繁体   English

预期的学说查询构建器语法错误 =, <, <=, <>, >, >=, !=, got end of string

[英]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.

相关问题 Querybuilder:错误:预期的字符串结尾,得到了&#39;(&#39; - Querybuilder : Error: Expected end of string, got '(' JOIN的原则查询错误:预期的字符串结尾,得到了“ I” - Doctrine Query Error for JOIN: Expected end of string, got 'I' 教义FIND_IN_SET导致错误:预期的字符串结尾,得到了&#39;(&#39; - Doctrine FIND_IN_SET leads to Error: Expected end of string, got '(' 语法错误:预期表达式已结束脚本 - Syntax Error:expected expression got end of script 尝试检索布尔值时出现的错误-行0,列111:错误:预期的字符串结尾,得到了“ 1” - Doctrine Error on attempting to retrieve a boolean value - line 0, col 111: Error: Expected end of string, got '1' 语法错误:第 0 行,第 72 列:错误:预期的字符串结尾,得到 'b6f037' - Syntax Error: line 0, col 72: Error: Expected end of string, got 'b6f037' 错误:预期文字,在 Doctrine 中得到“*” - Error: Expected Literal, got '*' in Doctrine 语法错误或访问冲突:1064 | 使用 Doctrine (QueryBuilder) 发送数组 - Syntax error or access violation: 1064 | Sending array using Doctrine (QueryBuilder) 具有Doctrine查询生成器的Symfony 3.0:[语法错误]行0,列7:错误:预期的已知函数,得到了“ WHERE” - Symfony 3.0 with Doctrine query builder: [Syntax Error] line 0, col 7: Error: Expected known function, got 'WHERE' Symfony格式错误:“给出了类型为“ Doctrine \\ ORM \\ QueryBuilder”的预期参数,“ Doctrine \\ ORM \\ Query”已给出” - Symfony Form Error: “Expected argument of type ”Doctrine\ORM\QueryBuilder“, ”Doctrine\ORM\Query“ given”
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM