来源:http://trac.seagullproject.org/wiki/Howto/DB/PagingRecordsets

分页Recordsets

下面是一个分页数据集的例子:

用法:

    $query = "SELECT preference_id, name, default_value FROM {$conf['table']['preference']}";
    $limit = $_SESSION['aPrefs']['resPerPage'];
    $pagerOptions = array(
        'mode'      => 'Sliding',
        'delta'     => 3,
        'perPage'   => $limit,
        'totalItems'=> $input->totalItems,
    );
 
    $aPagedData = SGL_DB::getPagedData($this->dbh, $query, $pagerOptions);
    $output->aPagedData = $aPagedData;
    if (is_array($aPagedData['data']) && count($aPagedData['data']] {
        $output->pager = ($aPagedData['totalItems'] <= $limit) ? false : true;
    }

然后在模板中调用分页子模板。该模板只在一个页面无法容纳所有的记录时包含(比如,现在有11个以上的记录而你指定每个页面显示10记录):

{if:pager}
  <flexy:include src="pager.html" />
{end:}
 
howto/db/pagingrecordsets.txt · 最后更改: 2010/05/30 00:21 (外部编辑)
 
Except where otherwise noted, content on this wiki is licensed under the following license:GNU Free Documentation License 1.2