Skip to content
Snippets Groups Projects
Select Git revision
  • master
  • release/8.0-perimetres
  • php84
  • 5.x
  • detached3
  • detached4
  • detached2
  • detached
  • 6.0.x
  • release/1.3.0
  • 6.x
  • pull_request_1
  • release-1.2.0
  • bg-php8
  • 5.1.2
  • 6.2.1
  • 6.2.0
  • 6.1.2
  • 6.1.1
  • 5.1.1
  • 6.0.5
  • 6.1.0
  • 5.1.0
  • 6.0.4
  • 6.0.3
  • 5.0.7
  • 6.0.2
  • 6.0.1
  • 6.0.0
  • 1.2.3
  • 5.0.6
  • 5.0.5
  • 1.2.2
  • 1.2.1
34 results

data.sql

Blame
  • Code owners
    Assign users and groups as approvers for specific file changes. Learn more.
    PasHistorise.php 1.92 KiB
    <?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;
        }
    }