Advertisement
michal_loksik

Untitled

Dec 5th, 2016
80
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.50 KB | None | 0 0
  1.     /**
  2.      * @return $this
  3.      */
  4.     public function withFiles() {
  5.         $this->onPostFetch[] = function(\Kdyby\Persistence\Query $self, \Kdyby\Persistence\Queryable $repository, \Iterator $iterator) {
  6.             $ids = array_map(function($row) {
  7.                 return $row->id;
  8.             }, iterator_to_array($iterator));
  9.  
  10.             $repository->createQueryBuilder('e')->select('e.id')
  11.                 ->leftJoin('e.files', 'f')
  12.                 ->andWhere('e.id IN (:ids)', $ids)
  13.                 ->addGroupBy('e.id')
  14.                 ->getQuery()
  15.                 ->getResult();
  16.         };
  17.  
  18.         return $this;
  19.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement