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

Ajout temporaire de la fonction Doctrine pasHistorise

parent 610ce710
No related branches found
No related tags found
No related merge requests found
Pipeline #7659 failed
......@@ -3,6 +3,7 @@
namespace UnicaenOracle;
use Doctrine\DBAL\Driver\OCI8\Driver as OCI8;
use UnicaenOracle\ORM\Query\Functions\PasHistorise;
use UnicaenOracle\Controller\Factory\IndexControllerFactory;
use UnicaenOracle\Controller\IndexController;
use UnicaenOracle\DBAL\Event\Listeners\OracleSessionInit;
......@@ -29,6 +30,9 @@ return [
// fonctions du package PL/SQL "UNICAEN_ORACLE" (cf. "../data/package.sql")
'compriseEntre' => CompriseEntre::class,
// fonction réalisant compriseEntre(histoCreation, histoDestruction, dateObservation)
'pasHistorise' => PasHistorise::class,
],
],
],
......
<?php
namespace UnicaenOracle\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;
/**
* Fonction DQL maison "pasHistorise()".
*
* NB: le format DQL attendu est "pasHistorise(EntityExpression)".
* Exemples :
* <pre>
* $qb->andWhere("1 = pasHistorise(sr)")
* $qb->andWhere("1 = pasHistorise(int.serviceReferentiel)")
* </pre>
*
* Fait appel à la fonction Oracle UNICAEN_ORACLE.COMPRISE_ENTRE().
*/
class PasHistorise extends FunctionNode
{
public $alias;
public $dateObservation;
/**
* Parsing.
*
* NB: le format DQL attendu est "pasHistorise(EntityExpression)".
* Exemple :
* pasHistorise(s)
* pasHistorise(int.serviceReferentiel)
*
* @param Parser $parser
*/
public function parse(Parser $parser)
{
$lexer = $parser->getLexer();
$parser->match(Lexer::T_IDENTIFIER);
$parser->match(Lexer::T_OPEN_PARENTHESIS);
$this->alias = $parser->EntityExpression();
if(Lexer::T_COMMA === $lexer->lookahead['type']){
$parser->match(Lexer::T_COMMA);
$this->dateObservation = $parser->ArithmeticPrimary();
}
$parser->match(Lexer::T_CLOSE_PARENTHESIS);
}
/**
* Génère le code SQL.
*
* @param SqlWalker $sqlWalker
* @return string
*/
public function getSql(SqlWalker $sqlWalker)
{
$expr1 = clone($this->alias);
$expr2 = clone($this->alias);
$expr1->field = 'histoCreation';
$expr2->field = 'histoDestruction';
$sql = sprintf('UNICAEN_ORACLE.COMPRISE_ENTRE(%s, %s, %s)',
$expr1->dispatch($sqlWalker),
$expr2->dispatch($sqlWalker),
$this->dateObservation ? $this->dateObservation->dispatch($sqlWalker) : 'null');
return $sql;
}
}
\ 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