在我的项目中,我有以下DQL扩展
namespace Freedom\Doctrine\ORM\AST\Functions;
use Doctrine\ORM\Query\AST\Functions\FunctionNode;
use Doctrine\ORM\Query\Lexer;
use Doctrine\ORM\Query\Parser;
use Doctrine\ORM\Query\SqlWalker;
/**
* MatchAgainstFunction ::=
* "MATCH" "(" StateFieldPathExpression {"," StateFieldPathExpression}* ")" "AGAINST" "("
* StringPrimary ["BOOLEAN"] ["EXPAND"] ")"
*/
class MatchAgainstFunction extends FunctionNode
{
/** @var array list of \Doctrine\ORM\Query\AST\PathExpression */
protected $pathExp = null;
/** @var string */
protected $against = null;
/** @var boolean */
protected $booleanMode = false;
/** @var boolean */
protected $queryExpansion = false;
public function parse(Parser $parser)
{
// match
$parser->match(Lexer::T_IDENTIFIER);
$parser->match(Lexer::T_OPEN_PARENTHESIS);
// first Path Expression is mandatory
$this->pathExp = array();
$this->pathExp[] = $parser->StateFieldPathExpression();
// Subsequent Path Expressions are optional
$lexer = $parser->getLexer();
while ($lexer->isNextToken(Lexer::T_COMMA)) {
$parser->match(Lexer::T_COMMA);
$this->pathExp[] = $parser->StateFieldPathExpression();
}
$parser->match(Lexer::T_CLOSE_PARENTHESIS);
// against
if (strtolower($lexer->lookahead['value']) !== 'against') {
$parser->syntaxError('against');
}
$parser->match(Lexer::T_IDENTIFIER);
$parser->match(Lexer::T_OPEN_PARENTHESIS);
$this->against = $parser->StringPrimary();
if (strtolower($lexer->lookahead['value']) === 'boolean') {
$parser->match(Lexer::T_IDENTIFIER);
$this->booleanMode = true;
}
if (strtolower($lexer->lookahead['value']) === 'expand') {
$parser->match(Lexer::T_IDENTIFIER);
$this->queryExpansion = true;
}
$parser->match(Lexer::T_CLOSE_PARENTHESIS);
}
public function getSql(SqlWalker $walker)
{
$fields = array();
foreach ($this->pathExp as $pathExp) {
$fields[] = $pathExp->dispatch($walker);
}
$against = $walker->walkStringPrimary($this->against)
. ($this->booleanMode ? ' IN BOOLEAN MODE' : '')
. ($this->queryExpansion ? ' WITH QUERY EXPANSION' : '');
return sprintf('MATCH (%s) AGAINST (%s)', implode(', ', $fields), $against);
}
}
在我的DQL中我有
$builder->andWhere('MATCH (t.title) AGAINST (:title)')
->setParameter('title', $param);
我收到错误
[语法错误]第0行,第204行:错误:预期=,&lt;,&lt; =,&lt;&gt;,&gt;,&gt; =,!=,得到&#39;订购&#39; < / p>
我在DQL中的andWhere后面有一个订单。
有谁知道为什么Doctrine正在寻找比较运算符?
答案 0 :(得分:0)
我已经弄清楚了。我将DQL更改为
opencv 3
现在似乎正在运作。