1、执行SQL语句
2、读取单条信息
print_r($A);
3、计算总数
echo $A['num'];
4、读取多条信息
$result = $db->query("SELECt * FROM `{$DT_PRE}table` WHERe `xxx`='yyy' ORDER BY `zzz` DESC LIMIT 0,10");
while($r = $db->fetch_array($result)) {
$A[] = $r;
}
print_r($A);
5、分页
$r = $db->get_one("SELECt COUNT(*) AS num FROM `{$DT_PRE}table` WHERe `xxx`='yyy'");
$pages = pages($r['num'], $page, $pagesize);
$result = $db->query("SELECt * FROM `{$DT_PRE}table` WHERe `xxx`='yyy' ORDER BY `zzz` DESC LIMIT $offset,$pagesize");
while($r = $db->fetch_array($result)) {
$A[] = $r;
}
print_r($A); echo $pages;
如果在函数中使用数据库操作,需要先进行global $db;