Loading config/module.config.php +2 −0 Original line number Diff line number Diff line Loading @@ -20,6 +20,7 @@ use UnicaenApp\Message\View\Helper\MessageHelperFactory; use UnicaenApp\Mvc\RedirectResponse; use UnicaenApp\Mvc\RedirectResponseFactory; use UnicaenApp\ORM\Query\Functions\Chr; use UnicaenApp\ORM\Query\Functions\Coalesce; use UnicaenApp\ORM\Query\Functions\CompriseEntre; use UnicaenApp\ORM\Query\Functions\PasHistorise; use UnicaenApp\ORM\Query\Functions\Replace; Loading Loading @@ -467,6 +468,7 @@ return [ 'pasHistorise' => PasHistorise::class, 'replace' => Replace::class, 'chr' => Chr::class, 'coalesce' => Coalesce::class, ], ], ], Loading src/UnicaenApp/ORM/Query/Functions/Coalesce.php 0 → 100644 +38 −0 Original line number Diff line number Diff line <?php namespace UnicaenApp\ORM\Query\Functions; use Doctrine\ORM\Query\AST\Functions\FunctionNode; use Doctrine\ORM\Query\AST\Node; use Doctrine\ORM\Query\Lexer; use Doctrine\ORM\Query\Parser; use Doctrine\ORM\Query\SqlWalker; class Coalesce extends FunctionNode { public Node $inputString; public Node $replacementString; /** * @throws \Doctrine\ORM\Query\QueryException */ public function parse(Parser $parser): void { $parser->match(Lexer::T_IDENTIFIER); $parser->match(Lexer::T_OPEN_PARENTHESIS); $this->inputString = $parser->StringPrimary(); $parser->match(Lexer::T_COMMA); $this->replacementString = $parser->StringPrimary(); $parser->match(Lexer::T_CLOSE_PARENTHESIS); } /** * @throws \Doctrine\ORM\Query\AST\ASTException */ public function getSql(SqlWalker $sqlWalker): string { return sprintf('coalesce(%s, %s)', $this->inputString->dispatch($sqlWalker), $this->replacementString->dispatch($sqlWalker)); } } No newline at end of file Loading
config/module.config.php +2 −0 Original line number Diff line number Diff line Loading @@ -20,6 +20,7 @@ use UnicaenApp\Message\View\Helper\MessageHelperFactory; use UnicaenApp\Mvc\RedirectResponse; use UnicaenApp\Mvc\RedirectResponseFactory; use UnicaenApp\ORM\Query\Functions\Chr; use UnicaenApp\ORM\Query\Functions\Coalesce; use UnicaenApp\ORM\Query\Functions\CompriseEntre; use UnicaenApp\ORM\Query\Functions\PasHistorise; use UnicaenApp\ORM\Query\Functions\Replace; Loading Loading @@ -467,6 +468,7 @@ return [ 'pasHistorise' => PasHistorise::class, 'replace' => Replace::class, 'chr' => Chr::class, 'coalesce' => Coalesce::class, ], ], ], Loading
src/UnicaenApp/ORM/Query/Functions/Coalesce.php 0 → 100644 +38 −0 Original line number Diff line number Diff line <?php namespace UnicaenApp\ORM\Query\Functions; use Doctrine\ORM\Query\AST\Functions\FunctionNode; use Doctrine\ORM\Query\AST\Node; use Doctrine\ORM\Query\Lexer; use Doctrine\ORM\Query\Parser; use Doctrine\ORM\Query\SqlWalker; class Coalesce extends FunctionNode { public Node $inputString; public Node $replacementString; /** * @throws \Doctrine\ORM\Query\QueryException */ public function parse(Parser $parser): void { $parser->match(Lexer::T_IDENTIFIER); $parser->match(Lexer::T_OPEN_PARENTHESIS); $this->inputString = $parser->StringPrimary(); $parser->match(Lexer::T_COMMA); $this->replacementString = $parser->StringPrimary(); $parser->match(Lexer::T_CLOSE_PARENTHESIS); } /** * @throws \Doctrine\ORM\Query\AST\ASTException */ public function getSql(SqlWalker $sqlWalker): string { return sprintf('coalesce(%s, %s)', $this->inputString->dispatch($sqlWalker), $this->replacementString->dispatch($sqlWalker)); } } No newline at end of file