Pagerfanta/DoctrineORM/WhereInWalker.php
public function walkSelectStatement(SelectStatement $AST)
    {
        $parent = null;
        $parentName = null;
        foreach ($this->_getQueryComponents() as $dqlAlias => $qComp) {
            if (array_key_exists('parent', $qComp) && $qComp['parent'] === null && $qComp['nestingLevel'] == 0) {
                $parent = $qComp;
                $parentName = $dqlAlias;
                break;
            }
        }

        $pathExpression = new PathExpression(
            PathExpression::TYPE_STATE_FIELD, $parentName, $parent['metadata']->getSingleIdentifierFieldName()
        );
        $pathExpression->type = PathExpression::TYPE_STATE_FIELD;

        $count = $this->_getQuery()->getHint('id.count');

        if ($count > 0) {
            // in new doctrine 2.2 version there's a different expression
            if (property_exists('Doctrine\ORM\Query\AST\InExpression', 'expression')) {
                $arithmeticExpression = new ArithmeticExpression();
                $arithmeticExpression->simpleArithmeticExpression = new SimpleArithmeticExpression(
                    array($pathExpression)
                );
                $inExpression = new InExpression($arithmeticExpression);
            } else {
                $inExpression = new InExpression($pathExpression);
            }
            $ns = $this->_getQuery()->getHint('pg.ns');
            for ($i = 1; $i <= $count; $i++) {
                $inExpression->literals[] = new InputParameter(":{$ns}_$i");
            }
        } else {
            $inExpression = new NullComparisonExpression($pathExpression);
            $inExpression->not = false;
        }
        $conditionalPrimary = new ConditionalPrimary;
        $conditionalPrimary->simpleConditionalExpression = $inExpression;

        // if no existing whereClause
        if ($AST->whereClause === null) {
            $AST->whereClause = new WhereClause(
                new ConditionalExpression(array(
                    new ConditionalTerm(array(
                        new ConditionalFactor($conditionalPrimary)
                    ))
                ))
            );
        } else { // add to the existing using AND
            // existing AND clause
            if ($AST->whereClause->conditionalExpression instanceof ConditionalTerm) {
                $AST->whereClause->conditionalExpression->conditionalFactors[] = $conditionalPrimary;
            }
            // single clause where
            elseif ($AST->whereClause->conditionalExpression instanceof ConditionalPrimary) {
                $AST->whereClause->conditionalExpression = new ConditionalExpression(
                    array(
                        new ConditionalTerm(
                            array(
                                $AST->whereClause->conditionalExpression,
                                $conditionalPrimary
                            )
                        )
                    )
                );
            }
            // an OR or NOT clause
            elseif ($AST->whereClause->conditionalExpression instanceof ConditionalExpression
                || $AST->whereClause->conditionalExpression instanceof ConditionalFactor
            ) {
                $tmpPrimary = new ConditionalPrimary;
                $tmpPrimary->conditionalExpression = $AST->whereClause->conditionalExpression;
                $AST->whereClause->conditionalExpression = new ConditionalTerm(
                    array(
                        $tmpPrimary,
                        $conditionalPrimary,
                    )
                );
            } else {
                // error check to provide a more verbose error on failure
                throw new \RuntimeException("Unknown conditionalExpression in WhereInWalker");
            }
        }
    }
public function walkSelectStatement(SelectStatement $AST)
    {
        $parent = null;
        $parentName = null;
        foreach ($this->_getQueryComponents() as $dqlAlias => $qComp) {
            if (array_key_exists('parent', $qComp) && $qComp['parent'] === null && $qComp['nestingLevel'] == 0) {
                $parent = $qComp;
                $parentName = $dqlAlias;
                break;
            }
        }

        $pathExpression = new PathExpression(
            PathExpression::TYPE_STATE_FIELD, $parentName, $parent['metadata']->getSingleIdentifierFieldName()
        );
        $pathExpression->type = PathExpression::TYPE_STATE_FIELD;

        $count = $this->_getQuery()->getHint('id.count');

        if ($count > 0) {
            // in new doctrine 2.2 version there's a different expression
            if (property_exists('Doctrine\ORM\Query\AST\InExpression', 'expression')) {
                $arithmeticExpression = new ArithmeticExpression();
                $arithmeticExpression->simpleArithmeticExpression = new SimpleArithmeticExpression(
                    array($pathExpression)
                );
                $inExpression = new InExpression($arithmeticExpression);
            } else {
                $inExpression = new InExpression($pathExpression);
            }
            $ns = $this->_getQuery()->getHint('pg.ns');
            for ($i = 1; $i <= $count; $i++) {
                $inExpression->literals[] = new InputParameter(":{$ns}_$i");
            }
        } else {
            $inExpression = new NullComparisonExpression($pathExpression);
            $inExpression->not = false;
        }
        $conditionalPrimary = new ConditionalPrimary;
        $conditionalPrimary->simpleConditionalExpression = $inExpression;

        // if no existing whereClause
        if ($AST->whereClause === null) {
            $AST->whereClause = new WhereClause(
                new ConditionalExpression(array(
                    new ConditionalTerm(array(
                        new ConditionalFactor($conditionalPrimary)
                    ))
                ))
            );
        } else { // add to the existing using AND
            // existing AND clause
            if ($AST->whereClause->conditionalExpression instanceof ConditionalTerm) {
                $AST->whereClause->conditionalExpression->conditionalFactors[] = $conditionalPrimary;
            }
            // single clause where
            elseif ($AST->whereClause->conditionalExpression instanceof ConditionalPrimary) {
                $AST->whereClause->conditionalExpression = new ConditionalExpression(
                    array(
                        new ConditionalTerm(
                            array(
                                $AST->whereClause->conditionalExpression,
                                $conditionalPrimary
                            )
                        )
                    )
                );
            }
            // an OR or NOT clause
            elseif ($AST->whereClause->conditionalExpression instanceof ConditionalExpression
                || $AST->whereClause->conditionalExpression instanceof ConditionalFactor
            ) {
                $tmpPrimary = new ConditionalPrimary;
                $tmpPrimary->conditionalExpression = $AST->whereClause->conditionalExpression;
                $AST->whereClause->conditionalExpression = new ConditionalTerm(
                    array(
                        $tmpPrimary,
                        $conditionalPrimary,
                    )
                );
            } else {
                // error check to provide a more verbose error on failure
                throw new \RuntimeException("Unknown conditionalExpression in WhereInWalker");
            }
        }
    }
public function walkSelectStatement ( SelectStatement $ AST ) { $ parent = null ; $ parentName = null ; foreach ( $ this -> _getQueryComponents ( ) as $ dqlAlias => $ qComp ) { if ( array_key_exists ( 'parent' , $ qComp ) && $ qComp [ 'parent' ] === null && $ qComp [ 'nestingLevel' ] == 0 ) { $ parent = $ qComp ; $ parentName = $ dqlAlias ; break ; } } $ pathExpression = new PathExpression ( PathExpression :: TYPE_STATE_FIELD , $ parentName , $ parent [ 'metadata' ] -> getSingleIdentifierFieldName ( ) ) ; $ pathExpression -> type = PathExpression :: TYPE_STATE_FIELD ; $ count = $ this -> _getQuery ( ) -> getHint ( 'id.count' ) ; if ( $ count > 0 ) { // in new doctrine 2.2 version there's a different expression if ( property_exists ( 'Doctrine\ORM\Query\AST\InExpression' , 'expression' ) ) { $ arithmeticExpression = new ArithmeticExpression ( ) ; $ arithmeticExpression -> simpleArithmeticExpression = new SimpleArithmeticExpression ( array ( $ pathExpression ) ) ; $ inExpression = new InExpression ( $ arithmeticExpression ) ; } else { $ inExpression = new InExpression ( $ pathExpression ) ; } $ ns = $ this -> _getQuery ( ) -> getHint ( 'pg.ns' ) ; for ( $ i = 1 ; $ i <= $ count ; $ i ++ ) { $ inExpression -> literals [ ] = new InputParameter ( ":{$ns}_$i" ) ; } } else { $ inExpression = new NullComparisonExpression ( $ pathExpression ) ; $ inExpression -> not = false ; } $ conditionalPrimary = new ConditionalPrimary ; $ conditionalPrimary -> simpleConditionalExpression = $ inExpression ; // if no existing whereClause if ( $ AST -> whereClause === null ) { $ AST -> whereClause = new WhereClause ( new ConditionalExpression ( array ( new ConditionalTerm ( array ( new ConditionalFactor ( $ conditionalPrimary ) ) ) ) ) ) ; } else { // add to the existing using AND // existing AND clause if ( $ AST -> whereClause -> conditionalExpression instanceof ConditionalTerm ) { $ AST -> whereClause -> conditionalExpression -> conditionalFactors [ ] = $ conditionalPrimary ; } // single clause where elseif ( $ AST -> whereClause -> conditionalExpression instanceof ConditionalPrimary ) { $ AST -> whereClause -> conditionalExpression = new ConditionalExpression ( array ( new ConditionalTerm ( array ( $ AST -> whereClause -> conditionalExpression , $ conditionalPrimary ) ) ) ) ; } // an OR or NOT clause elseif ( $ AST -> whereClause -> conditionalExpression instanceof ConditionalExpression || $ AST -> whereClause -> conditionalExpression instanceof ConditionalFactor ) { $ tmpPrimary = new ConditionalPrimary ; $ tmpPrimary -> conditionalExpression = $ AST -> whereClause -> conditionalExpression ; $ AST -> whereClause -> conditionalExpression = new ConditionalTerm ( array ( $ tmpPrimary , $ conditionalPrimary , ) ) ; } else { // error check to provide a more verbose error on failure throw new \ RuntimeException ( "Unknown conditionalExpression in WhereInWalker" ) ; } } }
Replaces the whereClause in the AST

Generates a clause equivalent to WHERE IN (:pgid_1, :pgid_2, ...)

The parameter namespace (pgid) is retrieved from the pg.ns query hint
The total number of parameters is retrieved from the id.count query hint

@param  SelectStatement $AST
@return void
Replaces the whereClause in the AST