zend框架paginator不起作用?

时间:2015-11-23 10:10:55

标签: php zend-framework pagination

我使用ZendFramework Paginator,我有一些这样的代码:

    $defaultCount=1000;
    $db = Zend_Db_Table::getDefaultAdapter();
    $select = $db->select();

    $select->from(array('u' => 'core_users'));
    $select->join(array('ur' => 'core_users_roles'), 'u.uid = ur.uid');
    $select->join(array('r' => 'core_roles'), 'r.rid = ur.rid');

    $adapter=new Zend_Paginator_Adapter_DbSelect($select);

    $adapter->setRowCount($db->select()->from('core_users',array(Zend_Paginator_Adapter_DbSelect::ROW_COUNT_COLUMN =>'uid')));

    $paginator= new Zend_Paginator($adapter);
    $paginator->setItemCountPerPage($defaultCount);
    $paginator->setCurrentPageNumber($page);

但是,我无法从DbSelect Adapter获取所有数据。当我删除$ defaultCount时,它总是给我20个总数据(默认,我猜)。我应该使用单桌吗?

1 个答案:

答案 0 :(得分:0)

$db->select()->from('core_users',array(Zend_Paginator_Adapter_DbSelect::ROW_COUNT_COLUMN =>'uid'))

给我错误的号码。我使用硬编码,对我有用。