$entityManager = $this->getServiceLocator()->get('doctrine.entitymanager.orm_default'); $rsm = new \Doctrine\ORM\Query\ResultSetMapping; $rsm->addEntityResult('SchoolAdmin\Entity\Maptechclass', 'Mt'); $rsm->addFieldResult('Mt', 'map_tech_class_id', 'mapTechClassID'); $rsm->addFieldResult('Mt', 'map_tech_id', 'mapTechID'); $rsm->addEntityResult('SchoolAdmin\Entity\Teacher', 'Th'); $rsm->addFieldResult('Th', 'th_id', 'th_id'); $rsm->addFieldResult('Th', 'th_first_name', 'th_first_name'); $rsm->addFieldResult('Th', 'th_last_name', 'th_last_name'); $rsm->addEntityResult('SchoolAdmin\Entity\Classes', 'Cs'); $Q = "SELECT Mt.map_tech_class_id , Mt.map_tech_id , Th.th_id, Th.th_first_name, Th.th_last_name, Cs.class_name FROM maptechclass Mt LEFT JOIN teacher Th ON Mt.map_tech_id=Th.th_teacher_id LEFT JOIN classes Cs ON Mt.map_class_id=Cs.class_id WHERE Mt.map_sch_id=49"; $query = $entityManager->createNativeQuery($Q, $rsm); $auctions = $query->getResult(); return new ViewModel(array('paginator' => $auctions));
可捕获致命错误:传递给Doctrine \ ORM \ Tools \ Pagination \ Paginator :: cloneQuery()的参数1必须是Doctrine \ ORM \ Query的实例,给定数组,在D:\ xampp \ htdocs \ deltaspiral中调用第122行上的vendor \ doctrine \ orm \ lib \ Doctrine \ ORM \ Tools \ Pagination \ Paginator.php,在D:\ xampp \ htdocs \ deltaspiral \ vendor \ doctrine \ orm \ lib \ Doctrine \ ORM \ Tools \ Pagination \中定义第205行的Paginator.php
答案 0 :(得分:1)
返回$ query而不是返回$ qb-> result()。 $ query是Doctrine \ ORM \ Query的实例,而$ qb-result()返回结果数组。分页器需要查询,而不是结果!