zf2 Doctrine加入实体结果不在一个对象

时间:2018-05-31 17:12:07

标签: doctrine-orm zend-framework2 zend-framework3

当我运行foreach然后在第一次迭代中我得到表r行对象并且在下一次迭代中我得到表ke行的对象。一旦表ke行迭代完成,然后在下一次迭代中我得到表r下一行对象然后我得到表ke行对象。 这是我的回购。

public function getPagedSelfReview(array $criteria)
    {
        $query = $this->createQueryBuilder('r');
            $query ->select('r','ke')
                    ->leftJoin(
                        'User\Entity\KraEvaluation', 'ke', \Doctrine\ORM\Query\Expr\Join::WITH, 'r.id = ke.kraReview and ke.evaluatedBy = :userId'
                )
                    ->andWhere('r.user = :userId')
                    ->setMaxResults($criteria['limit'])
                    ->setFirstResult($criteria['offset'])
                    ->setParameter('userId', $criteria['userId'])
                    ;           
        $paginator = new Paginator( $query );
        return $paginator;
    }

示例:

0 - table r first row
1 - table ke first row (based on join match with r first row's column)
2 - table ke Second row (based on join match with r first row's column)
3 - table r Second row
4 - table ke first row (based on join match with r second row's column)
5 - table ke Second row (based on join match with r second row's column)

需要输入

0 - array(
 0=>table r first row,
 1=> array(
   0=>table ke first row (based on join match with r first row's column),
   1=>table ke second row (based on join match with r first row's column)
  )
 )
1- array(
 0=>table r Second row,
 1=>array(
   0=>table ke first row (based on join match with r Second row's column),
   1=>table ke second row (based on join match with r Second row's column)
  )
 )

0 个答案:

没有答案