drupal分页函数 pager_query()

        在程序中,查询分页是我们经常要用到的,drupal中提供了一个钩子函数 pager_query(),pager_query()是一个执行数据库查询分页函数,通过theme('pager')控制着分页的显示形式.drupal的分页函数的使用是很简单,如下的俩个例子
<?php
//无参直接查询,分页显示结果
function product_information_list(){
    $output = '';
    $rows = array();
    $header = array(
            array('data' => '产品标题'),
            array('data' => '产品品牌'),
            array('data' => '产品价格'),
            array('data' => '发布日期'),
    );
    $sql = "SELECT n.nid,n.title,n.created,p.field_brand_value,p.field_price_value FROM {node} n INNER JOIN {content_type_product} p ON n.nid = p.nid WHERE  n.type='product' ORDER BY n.nid DESC " ;
    $result = pager_query($sql,15);
    while($row = db_fetch_object($result)){
            $rows[] = array(
                    l($row->title, 'node/'.$row->nid),
                    $row->field_brand_value,
                    $row->field_price_value,
                    $row->created,
            );
        }
    if(!empty($rows)){
        $output .= theme_table($header, $rows);
        if(count($rows)>14){
         $output .= theme('pager');
        }
    }
    return $output;
}
//通过传递参数,分页显示查询结果
function product_information_list(){
    $arg=isset($_GET['argname'])?$_GET['argname']:'';
    $output = '';
    $rows = array();
    $header = array(
            array('data' => '产品标题'),
            array('data' => '产品品牌'),
            array('data' => '产品价格'),
            array('data' => '发布日期'),
    );
    $sql = "SELECT n.nid,n.title,n.created,p.field_brand_value,p.field_price_value FROM {node} n INNER JOIN {content_type_product} p ON n.nid = p.nid WHERE  n.type='product' AND n.title LIKE '%s' ORDER BY n.nid DESC " ;
    $result = pager_query(db_rewrite_sql($sql), 15, 0, NULL, $arg);
    while($row = db_fetch_object($result)){
        $rows[] = array(
                l($row->title, 'node/'.$row->nid),
                $row->field_brand_value,
                $row->field_price_value,
                $row->created,
        );
    }
    if(!empty($rows)){
        $output .= theme_table($header, $rows);
        if(count($rows)>14){
         $output .= theme('pager');
        }
    }else {
        $output .= theme_table($header).'对不起,没有您要查询的结果!';
        }
    return $output;
}

?>