Doctrine orm 如何使用zend framwork 2为条令2中的本机查询分页

Doctrine orm 如何使用zend framwork 2为条令2中的本机查询分页,doctrine-orm,pagination,zend-framework2,Doctrine Orm,Pagination,Zend Framework2,以下是我尝试过的: $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'

以下是我尝试过的:

$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','THU first_name','Th_first_name');
$rsm->addFieldResult('Th'、'Th_last_name'、'Th_last_name');
$rsm->addEntityResult('SchoolAdmin\Entity\Classes','Cs');
$Q=“选择Mt.map\U tech\U class\U id、Mt.map\U tech\U id、,
Th.Th_id,
Th.Th_名字,
Th.Th_姓,
Cs.class_名称
来自maptechclass Mt
左会师
在Mt.map\u tech\u id=Th.Th\u teacher\u id上
左连接类
在Mt.map\u class\u id=Cs.class\u id上
其中Mt.map\u sch\u id=49”;
$query=$entityManager->createNativeQuery($Q,$rsm);
$auctions=$query->getResult();
返回新的ViewModel(数组('paginator'=>$auctions));
但我得到了以下错误:

可捕获的致命错误:传递给条令\ORM\Tools\Pagination\Paginator::cloneQuery()的参数1必须是条令\ORM\Query的实例,给定数组,在第122行的D:\xampp\htdocs\deltaspiral\vendor\doctor\orm\lib\doctor\orm\Tools\Pagination\Paginator.php中调用,并在第205行的D:\xampp\htdocs\deltaspiral\vendor\doctor\orm\lib\doctor\orm\Tools\Pagination\Paginator.php中定义


返回
$query
而不是返回
$qb->result()
$query
条令\ORM\query的一个实例,而
$qb-result()
返回一个结果数组


分页器需要的是查询,而不是结果

你不能,条令如何知道如何使用可能未知的本机SQL进行分页?在任何情况下,为什么要使用本机SQL进行此查询?您可以使用普通的DQL完成相同的查询。