php 查询列表,php编写数据库操作:查询列表并分页

php编写数据库操作:查询列表并分页

### $db->get_list方法的使用

1.首先加载对应的数据库类

`$db = load_class('db');`

2.调用get_list方法

`$result = get_list($table, $where = '', $field = '*', $startid = 0, $pagesize = 200,$page = 0, $order = '', $group = '', $keyfield = '', $urlrule = '',$array = array(),$colspan = 10);`

3.分页的调用

`{$pages}`

***************************************************************

#### 文件:coreframe/app/link/admin/index.php

```php

// +----------------------------------------------------------------------

defined('IN_WZ') or exit('No direct script access allowed');

/**

* 友情链接

*/

load_class('admin');

class index extends WUZHI_admin {

private $db;

function __construct() {

$this->db = load_class('db');

}

/**

* 友情链接列表

*/

public function listing() {

$page = isset($GLOBALS['page']) ? intval($GLOBALS['page']) : 1;

$page = max($page,1);

$result = $this->db->get_list('link', '', '*', 0, 20,$page,'sort ASC');

$pages = $this->db->pages;

$total = $this->db->number;

include $this->template('listing');

}

}

```

***************************************************************

- $table 数据表名

- array|string $where 条件 ,数组或者字符串 .如:array('id'=>1,'cid'=>1) 或 `id`=1 AND `cid`=1

- string $field 要查询的字段

- int $startid 开始索引,如果是从第二条开始,那么则为1,mysql从0开始索引

- int $pagesize 每页显示数量,如果不分页,则显示为总数

- int $page 当前页

- string $order 排序

- string $group mysql group by 属性

- string $keyfield 以某字段名为结果索引

- string $urlrule url规则

- array $array url规则中的参数名和参数值,二维数组

- int $colspan 分页显示总列数

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值