29 lines
692 B
PHP
29 lines
692 B
PHP
<?php
|
|
declare(strict_types=1);
|
|
|
|
namespace App\Doctrine\DQL;
|
|
|
|
use Doctrine\ORM\Query\AST\Functions\FunctionNode;
|
|
use Doctrine\ORM\Query\{Lexer, Parser, SqlWalker};
|
|
|
|
/** TODO: check if still needed */
|
|
class Day extends FunctionNode
|
|
{
|
|
public $dateExpression;
|
|
|
|
public function parse(Parser $parser): void
|
|
{
|
|
$parser->match(Lexer::T_IDENTIFIER);
|
|
$parser->match(Lexer::T_OPEN_PARENTHESIS);
|
|
|
|
$this->dateExpression = $parser->ArithmeticPrimary();
|
|
|
|
$parser->match(Lexer::T_CLOSE_PARENTHESIS);
|
|
}
|
|
|
|
public function getSql(SqlWalker $sqlWalker): string
|
|
{
|
|
return 'date_trunc(\'day\', '.$this->dateExpression->dispatch($sqlWalker).')';
|
|
}
|
|
}
|