原则2分页器获得总结果
2022-08-30 18:56:48
我马上会说,我读了这个问题 Doctrine2 Paginator,但它没有给我足够的信息来说明我的问题的标题。
当我使用 Doctrine1 时,我用这样的代码得到了结果,例如:
$list = $this->query
->addSelect( 'SQL_CALC_FOUND_ROWS *' )
->offset( ( $this->currentPage - 1 ) * $this->perPage )
->limit( $this->perPage )
->execute( array(), \Doctrine_Core::HYDRATE_ARRAY_SHALLOW );
$totalRecords = SqlCalcFoundRowsEventListener::getFoundRowsCount();
$this->totalPages = ceil( $totalRecords / $this->perPage );
而且很棒。
现在,在使用 Doctrine2 时,我对如何获取具有相同查询的记录总量感到困惑,因为当前页面的结果有限。
任何帮助/建议将不胜感激。