0
/**
 * PGSearchFunction ::= "PG_SEARCH" "(" StateFieldPathExpression "," StringPrimary ")"
 */
class PGSearch extends FunctionNode
{
    public $searchColumn = null;
    public $search = null;

    public function parse(Parser $parser)
    {
        $parser->match(Lexer::T_IDENTIFIER);
        $parser->match(Lexer::T_OPEN_PARENTHESIS);
        $this->searchColumn = $parser->StateFieldPathExpression();
        $parser->match(Lexer::T_COMMA);
        $this->search = $parser->StringPrimary(); 
        $parser->match(Lexer::T_CLOSE_PARENTHESIS);
    }

    public function getSql(SqlWalker $sqlWalker)
    {
        return sprintf("%s @@ to_tsquery('english', %s)", $this->searchColumn->dispatch($sqlWalker), $this->search->dispatch($sqlWalker));

    }

}

[语法错误] 第 0 行,列 -1:错误:预期 =、<、<=、<>、>、>=、!=,得到字符串结尾。关于如何防止学说将其视为标准 SQL 表达式的任何建议?顺便说一句,使用学说 2.2。

4

1 回答 1

1

你应该能够做到$em->createQuery("SELECT i FROM MyBundle:Invoice i WHERE PG_SEARCH(i.search, 'virus') = true");

于 2013-02-25T07:36:05.170 回答