doctrineのリファレンスページや他のいくつかのソースに関する公式な指示に従ってきましたが、何が間違っているのか分かりません。 私のユーザー定義関数がロードされていないようです。 私はオートローダー設定でZF2 + Doctrine 2を使用しています。ここで zf2 + doctrineのユーザー定義関数2が動作しない
は、私が持っているものです:エラー:
[Syntax Error] line 0, col 7: Error: Expected IdentificationVariable | ScalarExpression | AggregateExpression | FunctionDeclaration | PartialObjectExpression | "(" Subselect ")" | CaseExpression, got 'FROM'
args : ["SELECT FROM CadastrosAuxiliares\Entity\Bairro b WHERE upper_tira_acento(b.uf) = :uf"] 0 : "SELECT FROM CadastrosAuxiliares\Entity\Bairro b WHERE upper_tira_acento(b.uf) = :uf" class : "Doctrine\ORM\Query\QueryException" file : "(...)/vendor/doctrine/orm/lib/Doctrine/ORM/Query/Parser.php" function : "dqlError" line : 448 type : "::"
doctrine.global.php
<?php
return array(
'doctrine' => array(
'configuration' => array(
'orm_default' => array(
'string_functions' => array(
'upper_tira_acento' => 'Application\DoctrineFunction\UpperTiraAcento'
),
)
)
)
);
UpperTiraAcento.php
<?php
namespace Application\DoctrineFunction;
use Doctrine\ORM\Query\Parser;
use Doctrine\ORM\Query\Lexer;
use Doctrine\ORM\Query\AST\Functions\FunctionNode;
use Doctrine\ORM\Query\SqlWalker;
class UpperTiraAcento extends FunctionNode
{
public $parameters = array();
const STRING_PARAM = 'string';
/**
* {@inheritdoc}
*/
public function parse(Parser $parser)
{
$parser->match(Lexer::T_IDENTIFIER);
$parser->match(Lexer::T_OPEN_PARENTHESIS);
$this->parameters[self::STRING_PARAM] = $parser->StringPrimary();
$parser->match(Lexer::T_CLOSE_PARENTHESIS);
}
public function getSql(SqlWalker $sqlWalker)
{
$string = $sqlWalker->walkStringPrimary($this->parameters[self::STRING_PARAM]);
return sprintf('dbo.upper_tira_acento(%s)',$string);
}
}
DQLビルダーの例:
$qbBairro = $em->createQueryBuilder()->from('CadastrosAuxiliares\Entity\Bairro', 'b');
$qbBairro->andWhere("upper_tira_acento(b.uf) = :uf")->setParameter('uf', $estado->getId());
誰もが、おそらく問題に何ができるかのいずれかのアイデアを持っていますか?
ご協力いただきありがとうございます。