mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-06-19 16:54:25 +00:00
54 lines
1.2 KiB
PHP
54 lines
1.2 KiB
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
/*
|
|
* Chill is a software for social workers
|
|
*
|
|
* For the full copyright and license information, please view
|
|
* the LICENSE file that was distributed with this source code.
|
|
*/
|
|
|
|
namespace Chill\MainBundle\Doctrine\DQL;
|
|
|
|
use Doctrine\ORM\Query\AST\Functions\FunctionNode;
|
|
use Doctrine\ORM\Query\Lexer;
|
|
|
|
class Replace extends FunctionNode
|
|
{
|
|
protected $from;
|
|
|
|
protected $string;
|
|
|
|
protected $to;
|
|
|
|
public function getSql(\Doctrine\ORM\Query\SqlWalker $sqlWalker): string
|
|
{
|
|
return 'REPLACE(' .
|
|
$this->string->dispatch($sqlWalker) .
|
|
', ' .
|
|
$this->from->dispatch($sqlWalker) .
|
|
', ' .
|
|
$this->to->dispatch($sqlWalker) .
|
|
')';
|
|
}
|
|
|
|
public function parse(\Doctrine\ORM\Query\Parser $parser): void
|
|
{
|
|
$parser->match(Lexer::T_IDENTIFIER);
|
|
$parser->match(Lexer::T_OPEN_PARENTHESIS);
|
|
|
|
$this->string = $parser->StringPrimary();
|
|
|
|
$parser->match(Lexer::T_COMMA);
|
|
|
|
$this->from = $parser->StringPrimary();
|
|
|
|
$parser->match(Lexer::T_COMMA);
|
|
|
|
$this->to = $parser->StringPrimary();
|
|
|
|
$parser->match(Lexer::T_CLOSE_PARENTHESIS);
|
|
}
|
|
}
|