我有一个包含来自数据库的数据的表,我希望它有一个分页程序,我有来自其他站点的示例( buildamodule.com)的所有代码,并且我的表get被呈现,但它不生成分页程序,尽管我有比限制更多的行:

函数:
function get_loyaltycodes(){
$headers = array(
array(
'data' => t('Code')
),
array(
'data' => t('Info')
),
array(
'data' => t('Points')
),
array(
'data' => t('Consumed by')
),
);
$limit = variable_get('codes_per_page',5);
$query = db_select('loyalty_codes','lc');
$query -> fields('lc',array('code','info','points','uid'))
-> orderBy('lc.info','ASC')
-> extend('PagerDefault')
-> limit($limit);
//to see all codes for a certain amount of points, just append the number of points to the URL
$arg = arg(2);
if($arg != '' && is_numeric($arg))
{
$query->condition('points', $arg);
}
// Fetch the result set.
$result = $query->execute();
$rows = array();
// Loop through each item and add to the $rows array.
foreach ($result as $row) {
$rows[] = array(
$row->code,
$row->info,
$row->points,
$row->uid,
);
}
// Format output.
$output = theme('table', array('header' => $headers, 'rows' => $rows)) . theme('pager');
return $output;$limit变量在设置表单中设置为5,在数据库中也设置为5。
有人知道为什么寻呼机没有显示吗?也许是输出的格式化中的一些东西?
非常感谢您的帮助!
发布于 2012-03-08 16:51:20
显然我不能正确登录,因为我在防火墙后面,无论如何,我似乎已经修复了它,尽管是愚蠢的错误:
查询中的‘->extend(‘PagerDefault’)扩展必须是菊花链中的第一个函数。如果不是,则不会出现错误,但该函数似乎未被调用。
$query = db_select('loyalty_codes','lc')
->extend('PagerDefault')
-> fields('lc',array('code','info','points','uid'))
-> orderBy('lc.info','ASC')
-> limit(5);//$limit);https://stackoverflow.com/questions/9614549
复制相似问题