Skip to content
Snippets Groups Projects
Select Git revision
  • 3118d29a7de099fa79a2f5a324bda9a993c7c260
  • master default protected
  • php84
  • detached4
  • detached5
  • detached3
  • detached
  • detached2
  • ll-php8-bs5
  • ll-php8
  • 4.x
  • 6.3.0
  • 6.2.5
  • 6.2.4
  • 6.2.3
  • 6.2.2
  • 6.2.1
  • 6.2.0
  • 6.1.0
  • 6.0.2
  • 6.0.1
  • 6.0.0
  • 5.0.3
  • 5.0.2
  • 5.0.1
  • 5.0
  • 4.2.1
  • 4.2
  • 4.1
  • 4.0
  • 3.0.2
31 results

autoload_classmap.php

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;
        }