Skip to content
Snippets Groups Projects
Commit d9c5ba53 authored by Bertrand Gauthier's avatar Bertrand Gauthier
Browse files

Ajout du support de 2 fonctions SQL oracle/postgres : replace() et chr()

parent 37e956af
No related branches found
No related tags found
No related merge requests found
Pipeline #10486 failed
CHANGELOG
=========
3.1.20
------
- Ajout du support de 2 fonctions SQL oracle/postgres : replace() et chr()
3.1.19
------
3.1.18
------
3.1.17
------
3.1.16
------
3.1.15
------
- Refactoring de HostLocalizationUnicaen pour éviter d'avoir les adresses des proxies et reverse proxies en dur dans le code. Passage en fichier de config pour que chacun puisse configurer dans son application.
......
......@@ -14,8 +14,10 @@ use UnicaenApp\Message\View\Helper\MessageHelper;
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\CompriseEntre;
use UnicaenApp\ORM\Query\Functions\PasHistorise;
use UnicaenApp\ORM\Query\Functions\Replace;
use UnicaenApp\Service\InstadiaServiceFactory;
use UnicaenApp\Service\Mailer\MailerService;
use UnicaenApp\Service\Mailer\MailerServiceFactory;
......@@ -487,6 +489,8 @@ return [
'string_functions' => [
'compriseEntre' => CompriseEntre::class,
'pasHistorise' => PasHistorise::class,
'replace' => Replace::class,
'chr' => Chr::class,
],
],
],
......
<?php
namespace UnicaenApp\ORM\Query\Functions;
use Doctrine\ORM\Query\AST\Functions\FunctionNode;
use Doctrine\ORM\Query\Lexer;
use Doctrine\ORM\Query\Parser;
use Doctrine\ORM\Query\SqlWalker;
class Chr extends FunctionNode
{
public $field;
public function parse(Parser $parser)
{
$parser->match(Lexer::T_IDENTIFIER);
$parser->match(Lexer::T_OPEN_PARENTHESIS);
$this->field = $parser->ArithmeticPrimary();
$parser->match(Lexer::T_CLOSE_PARENTHESIS);
}
public function getSql(SqlWalker $sqlWalker)
{
return sprintf('CHR(%s)', $this->field->dispatch($sqlWalker));
}
}
\ No newline at end of file
<?php
namespace UnicaenApp\ORM\Query\Functions;
use Doctrine\ORM\Query\AST\Functions\FunctionNode;
use Doctrine\ORM\Query\Lexer;
use Doctrine\ORM\Query\Parser;
use Doctrine\ORM\Query\SqlWalker;
class Replace extends FunctionNode
{
public $inputString;
public $searchString;
public $replacementString;
public function getSql(SqlWalker $sqlWalker)
{
return sprintf('REPLACE(%s, %s, %s)',
$this->inputString->dispatch($sqlWalker),
$this->searchString->dispatch($sqlWalker),
$this->replacementString->dispatch($sqlWalker));
}
public function parse(Parser $parser)
{
$parser->match(Lexer::T_IDENTIFIER);
$parser->match(Lexer::T_OPEN_PARENTHESIS);
$this->inputString = $parser->StringPrimary();
$parser->match(Lexer::T_COMMA);
$this->searchString = $parser->StringPrimary();
$parser->match(Lexer::T_COMMA);
$this->replacementString = $parser->StringPrimary();
$parser->match(Lexer::T_CLOSE_PARENTHESIS);
}
}
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment