CreateBuilder Doctrine2

0

Do you know any method of CreateBuilder (Doctrine), to read an array? Let me explain:

class ExamplesRepository extends EntityRepository {

public function FindArticulosPadresid($padre) {

    return $this->createQueryBuilder('seccion')
                    ->select('seccion.literal','seccion.id')
                    ->where('seccion.id IN(:tpadre)')
                    ->setParameter('tpadre', **array($tpadre))** 
                    ->getQuery()
                    ->getResult();
}

}

I'm passing you a $ tpadre array, which is very simple contains whole numbers:

    array(11) 
        { [0]=> int(4)
          [1]=> int(22)
          [2]=> int(2)
          [3]=> int(2)
          [4]=> int(1)
          [5]=> int(3)
          [6]=> int(4)
          [7]=> int(3)
          [8]=> int(2)
          [9]=> int(1)
          [10]=> int(3) } 

The problem esque only returns the first index (0), result of the QUERY Is there a Doctrine method that reads the entire array and returns all possible results?

Thank you.

    
asked by otacon070 21.10.2016 в 11:53
source

1 answer

0

You are passing the father array within an array, you are actually passing this:

array(1) {
 [0] => array(11) 
    { [0]=> int(4)
      [1]=> int(22)
      [2]=> int(2)
      [3]=> int(2)
      [4]=> int(1)
      [5]=> int(3)
      [6]=> int(4)
      [7]=> int(3)
      [8]=> int(2)
      [9]=> int(1)
      [10]=> int(3) 
    }
}

Try this:

return $this->createQueryBuilder('seccion')
                ->select('seccion.literal','seccion.id')
                ->where('seccion.id IN(:tpadre)')
                ->setParameter('tpadre', $tpadre) 
                ->getQuery()
                ->getResult();
    
answered by 02.11.2016 в 08:39