1

我有一个包含数据库数据的表,我希望它有一个寻呼机,我有来自其他站点的示例(buildamodule.com)的所有代码,并且我的表被渲染,但它不会生成寻呼机,虽然我的行数超过了限制:

在此处输入图像描述

功能:

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。

有人知道为什么寻呼机没有显示吗?也许输出格式中有一些东西?

非常感谢您的帮助!

4

1 回答 1

5

显然我无法正确登录,因为我在防火墙后面,无论如何我似乎已经修复了它,但愚蠢的错误:

查询中的‘->extend(‘PagerDefault’)扩展必须是菊花链中的第一个函数。如果没有,则没有错误,但似乎没有调用该函数。

$query = db_select('loyalty_codes','lc')
        ->extend('PagerDefault')
        -> fields('lc',array('code','info','points','uid'))
        -> orderBy('lc.info','ASC')
        -> limit(5);//$limit);
于 2012-03-08T08:51:19.687 回答