自己经常用的类库
时间:2007-04-30
来源:互联网
class.mysql.php
class.page.admin.php
<?
/*
*
*主要用于数据库的各种操作
*���t�w2007-04-01
*函数列表
function Err($sql = "") //错误处理函数
function TDatabase($config) //连接数据库函数
function SelectDb($database) //选择数据库函数
function Query($SQL) //执行数据库查询函数
function FetchArray($result) //将查询结果倒入到数组函数,可通过下标和字段名访问结果
function FetchRow($result) //从结果集中取得一行作为枚举数组
function FetchObject($result) //从结果集中取得一行作为对象,只能通过字段名访问结果
function FreeResult(&$result) //释放结果内存
function NumRows($result) //取得结果集中行的数目
function AffectedRows() //返回数据库查询影响的记录行数
function DatabaseClose() //关闭数据库
function getInsertID() //得到插入的最后一条纪录的行号
*
*
*/
class TDatabase
{
var $m_host; //主机
var $m_port; //端口
var $m_user; //账号
var $m_password; //密码
var $m_name; //数据库名
var $m_link; //连接字符串
function Err($sql = "") //错误处理函数
{
global $HTTP_HOST; //主机地址
//echo $HTTP_HOST;
if ($HTTP_HOST=="127.0.0.1" || $HTTP_HOST=="192.168.0.222" || $HTTP_HOST=="")
{
echo "<font color=red>error sql : </font><br>".$sql;
}
else
{
echo "系统调整";
}
exit;
}
function TDatabase($config) //连接数据库函数
{
$this->m_host = $config->mDbHost; //主机
$this->m_port = $config->mDbPort; //端口
$this->m_user = $config->mDbUser; //账号
$this->m_password = $config->mDbPassword; //密码
$this->m_name = $config->mDbDatabase; //数据库名
$real_host = $this->m_host.":".$this->m_port;
$this->m_link = mysql_connect($real_host,$this->m_user,$this->m_password) or die($this->Err(mysql_error()));
if ("" != $this->m_name)
{
mysql_select_db($this->m_name, $this->m_link) or die($this->Err());
}
}
function SelectDb($database) //选择数据库函数
{
$this->m_name = $database; //默认数据库
if ("" != $this->m_name)
{
mysql_select_db($this->m_name, $this->m_link) or die($this->Err(mysql_error()));
}
}
function Query($SQL) //执行数据库查询函数
{
// echo $SQL;
//$escaped_sql = mysql_real_escape_string($SQL); //转义 SQL 语句中使用的字符串中的特殊字符,并考虑到连接的当前字符集
$result=mysql_query($SQL,$this->m_link) or die($this->Err($SQL));
return $result;
}
function FetchArray($result) //将查询结果倒入到数组函数,可通过下标和字段名访问结果
{
$row=mysql_fetch_array($result);
return $row;
}
function FetchRow($result) //从结果集中取得一行作为枚举数组
{
$row=mysql_fetch_row($result);
return $row;
}
function FetchObject($result) //从结果集中取得一行作为对象,只能通过字段名访问结果
{
$row=mysql_fetch_object($result);
return $row;
}
function FreeResult(&$result) //释放结果内存
{
return mysql_free_result($result) or die($this->Err(mysql_error()));
}
function NumRows($result) //取得结果集中行的数目
{
$result=mysql_num_rows($result) or die($this->Err(mysql_error()));
return $result;
}
function AffectedRows() //返回数据库查询影响的记录行数
{
$result=mysql_affected_rows($this->m_link);
return $result;
}
function DatabaseClose() //关闭数据库
{
mysql_close($this->m_link) or die($this->Err(mysql_error()));
}
function getInsertID() //得到插入的最后一条纪录的行号
{
return mysql_insert_id($this->m_link);
}
function CheckDB($link,$db) //检查是否存在指定的数据库,返回结果为1说明存在,为0说明不存在。
{
if (isset($db) && isset($link))
{
$db_list = mysql_list_dbs($link);
$i = 0;
$cnt = mysql_num_rows($db_list);
while ($i < $cnt)
{
if (mysql_db_name($db_list, $i)==$db)
{
mysql_free_result($db_list);
return 1;
}
$i++;
}
mysql_free_result($db_list);
}
return 0;
}
function CheckTable($link,$db,$table) //检查是否存在指定的数据表,返回结果为1说明存在,为0说明不存在。
{
if (isset($db) && isset($table) && isset($link))
{
if($this->CheckDB($link,$db))
{
$result = mysql_list_tables($db,$link);
$cnt = mysql_num_rows($result);
$i = 0;
while ($i < $cnt)
{
if (mysql_tablename($result, $i)==$table)
{
mysql_free_result($result);
return 1;
}
$i++;
}
mysql_free_result($result);
}
}
return 0;
}
function GetInsertText($link,$db,$table,$db_new,$table_new,$where)
{
$sql_str = "";
if (isset($table) && isset($db))//数据库名与表名是否为空
{
if($this->CheckTable($link,$db,$table))//判断数据库与表是否存在
{
$fields = mysql_list_fields($db, $table, $link);
$columns = mysql_num_fields($fields); //得到字段的数量
$result = mysql_query("select * from ".$table." ".$where."",$link);
for ($i = 0; $i < $columns; $i++) {
$cl_name[$i] = mysql_field_name($fields, $i); //得到字段的名字
$cl_type[$i] = mysql_field_type($fields, $i); //得到字段的类型
}
while($row=mysql_fetch_array($result))//拆分结果
{
$sql_str .= "INSERT INTO `".$table_new."` ";
$sql_str1 = "(";
$sql_str2 = " VALUES (";
for ($i = 0; $i < $columns; $i++)
{
if ($i == $columns-1)
{
$sql_str1 .= "`".$cl_name[$i]."`)";
$sql_str2 .= ('int' == $cl_type[$i])?"".$row[$i].")":"'".$row[$i]."')";
}else{
$sql_str1 .= "`".$cl_name[$i]."`,";
$sql_str2 .= ('int' == $cl_type[$i])?"".$row[$i].",":"'".$row[$i]."',";
}
}
$sql_str .=$sql_str1.$sql_str2.";";
}
}
mysql_free_result($result);
return $sql_str;
}
}
}
############################################################
#标准调用范例
# include("class/class.config.php");
# include("class/class.mysql.php");
#
# $config = new Config;
# $mysql = new TDatabase($config); //new出的Config实例作为TDatabase类的实例的参数
# $sql = "select UserName from user where ID = 1";
# $result = $mysql->Query($sql);
# if ($mysql->AffectedRows != 0)
# {
# $row = $mysql->FetchArray($result);
# echo $row[0];
# }
# $mysql->DatabaseClose();
############################################################
?>
[ 本帖最后由 2599qiang 于 2007-4-30 13:53 编辑 ]
作者: 2599qiang 发布时间: 2007-04-30
/*
*
*主要用于设置数据库配置信息
*mysql -h 192.168.88.24 -u root
*
*/
if (!isset($mDbHost))
{
class Config
{
var $mDbHost = "localhost"; //主机
var $mDbUser = "root"; //账户
var $mDbPassword = "passw0rd"; //密码
var $mDbPort = "3306"; //端口
var $mDbDatabase = "vod"; //默认数据库
}
}
?>
作者: 2599qiang 发布时间: 2007-04-30
/*
*
*冷彦辰编写于2006-3-10 主要用于处理翻页
*
*
*/
class Page{
var $CountAll; //共有纪录数
var $CountPage; //每页显示记录数
var $Link; //显示 完整的分页信息
var $ForPage; //上一页
var $NextPage; //下一页
var $FirstPage; //第一页
var $LastPage; //最后一页
var $CurrPage; //第几页
var $PageNum; //共有多少页
var $Parameter; //参数
var $LimitNum; //不是统计全部记录,而是显示部分记录,例如共有100条记录,但是只统计显示前50条
function Page($sql, $num=30){
//初始化,统计记录数
$this->CountPage = $num;
global $mysql;
$sql = base64_decode($sql);
$result = $mysql->Query($sql);
if (0 != $mysql->AffectedRows()){
$row = $mysql->FetchArray($result);
$this->CountAll = $row[0];
}
else{
$this->CountAll = 0;
}
//print "共有 $this->CountAll <br>";
}
function ListPage($sql, $page=0,$sql_all,$other){
//查询,定义变量,获取数据
global $mysql;
//print "sql :$sql<br>";
if (isset($this->LimitNum) && $this->CountAll > $this->LimitNum){
$this->CountAll = $this->LimitNum;
}//更新总浏览记录数
$sql_src = $sql;
//if ($page > 0){
$sql = base64_decode($sql);
$sql_all = base64_decode($sql_all);
$sql_src = $sql;
//}
//echo $sql;
if (($this->CountAll % $this->CountPage) == 0)//统计共有多少页
$pagecount = (integer)($this->CountAll/$this->CountPage);
else
$pagecount = (integer)($this->CountAll/$this->CountPage)+1;
$this->PageNum = $pagecount;
if ($page > $this->PageNum)//如果页码超过页码总数则设为最大页码
$page = $this->PageNum;
if ($page <= 0)//如果页码小于等于零则将页码设置为1
$page = 1;
if ($this->CountAll == 0)
{
$this->CurrPage = 0;
}else{
$this->CurrPage = $page;
}
$first_start = ($page-1)*$this->CountPage;
$sql = $sql." limit ".$first_start.", ".$this->CountPage;
//print "2:$sql<br>";
$result = $mysql->Query($sql);
if (0 != $mysql->AffectedRows()){
$i = 0;
while($row = $mysql->FetchArray($result)){
$array[$i] = $row;
//print "name:".$array[$i][Name]."<br>";
$i++;
}
}
$sql = base64_encode($sql_src);
$sql_all = base64_encode($sql_all);
if ($pagecount >1){
if($page == 1){
$nextpage = $page+1;
$forpage = 1;
$this->Link = "<button onClick=\"javascript:location.href='?query_sql=$sql&query_page=$nextpage".$this->Parameter."&sql_all=".$sql_all."".$other."'\" class=\"button_a\" style=\"width:30;height:22\";><img src=\"images/next.gif\" align=\"absmiddle\"> </button><button onClick=\"javascript:location.href='?query_sql=$sql&query_page=$pagecount".$this->Parameter."&sql_all=".$sql_all."".$other."'\" class=\"button_a\" style=\"width:30;height:22\";><img src=\"images/prev_end.gif\" align=\"absmiddle\"> </button>";
$this->NextPage = "<button onClick=\"javascript:location.href='?query_sql=$sql&query_page=$nextpage".$this->Parameter."&sql_all=".$sql_all."".$other."'\" class=\"button_a\" style=\"width:30;height:22\";><img src=\"images/next.gif\" align=\"absmiddle\"> </button>";
$this->LastPage = "<button onClick=\"javascript:location.href='?query_sql=$sql&query_page=$pagecount".$this->Parameter."&sql_all=".$sql_all."".$other."'\" class=\"button_a\" style=\"width:30;height:22\";><img src=\"images/prev_end.gif\" align=\"absmiddle\"> </button>";
}
else if(($page > 1)&&($page < $pagecount)) {
$forpage = $page-1;
$nextpage = $page+1;
$this->Link = "<button onClick=\"javascript:location.href='?query_sql=$sql&query_page=1".$this->Parameter."&sql_all=".$sql_all."".$other."'\" class=\"button_a\" style=\"width:30;height:22\";><img src=\"images/prev_top.gif\" align=\"absmiddle\"> </button><button onClick=\"javascript:location.href='?query_sql=$sql&query_page=$forpage".$this->Parameter."&sql_all=".$sql_all."".$other."'\" class=\"button_a\" style=\"width:30;height:22\";><img src=\"images/prev.gif\" align=\"absmiddle\"> </button><button onClick=\"javascript:location.href='?query_sql=$sql&query_page=$nextpage".$this->Parameter."&sql_all=".$sql_all."".$other."'\" class=\"button_a\" style=\"width:30;height:22\";><img src=\"images/next.gif\" align=\"absmiddle\"> </button><button onClick=\"javascript:location.href='?query_sql=$sql&query_page=$pagecount".$this->Parameter."&sql_all=".$sql_all."".$other."'\" class=\"button_a\" style=\"width:30;height:22\";><img src=\"images/prev_end.gif\" align=\"absmiddle\"> </button>";
$this->ForPage = "<button onClick=\"javascript:location.href='?query_sql=$sql&query_page=$forpage".$this->Parameter."&sql_all=".$sql_all."".$other."'\" class=\"button_a\" style=\"width:30;height:22\";><img src=\"images/prev.gif\" align=\"absmiddle\"> </button>";
$this->NextPage = "<button onClick=\"javascript:location.href='?query_sql=$sql&query_page=$nextpage".$this->Parameter."&sql_all=".$sql_all."".$other."'\" class=\"button_a\" style=\"width:30;height:22\";><img src=\"images/next.gif\" align=\"absmiddle\"> </button>";
$this->FirstPage = "<button onClick=\"javascript:location.href='?query_sql=$sql&query_page=1".$this->Parameter."&sql_all=".$sql_all."".$other."'\" class=\"button_a\" style=\"width:30;height:22\";><img src=\"images/prev_top.gif\" align=\"absmiddle\"> </button>";
$this->LastPage = "<button onClick=\"javascript:location.href='?query_sql=$sql&query_page=$pagecount".$this->Parameter."&sql_all=".$sql_all."".$other."'\" class=\"button_a\" style=\"width:30;height:22\";><img src=\"images/prev_end.gif\" align=\"absmiddle\"> </button>";
}
else if ($page = $pagecount){
$forpage = $page-1;
$nextpage = 1;
$this->Link = "<button onClick=\"javascript:location.href='?query_sql=$sql&query_page=1".$this->Parameter."&sql_all=".$sql_all."".$other."'\" class=\"button_a\" style=\"width:30;height:22\";><img src=\"images/prev_top.gif\" align=\"absmiddle\"> </button><button onClick=\"javascript:location.href='?query_sql=$sql&query_page=$forpage".$this->Parameter."&sql_all=".$sql_all."".$other."'\" class=\"button_a\" style=\"width:30;height:22\";><img src=\"images/prev.gif\" align=\"absmiddle\"> </button>";
$this->FirstPage = "<button onClick=\"javascript:location.href='?query_sql=$sql&query_page=1".$this->Parameter."&sql_all=".$sql_all."".$other."'\" class=\"button_a\" style=\"width:30;height:22\";><img src=\"images/prev_top.gif\" align=\"absmiddle\"> </button>";
$this->ForPage = "<button onClick=\"javascript:location.href='?query_sql=$sql&query_page=$forpage".$this->Parameter."&sql_all=".$sql_all."".$other."'\" class=\"button_a\" style=\"width:30;height:22\";><img src=\"images/prev.gif\" align=\"absmiddle\"> </button>";
}
}
else{
$this->Link = ' ';
}
return $array;//$array;
}
}
/***************
使用例子
include("class.config.php");
include("class.mysql.php");
include("class.page.php");
global $mysql;
$config = new Config;
$mysql = new TDatabase($config);
$query_all = "select count(*) from user";
$page_object = new Page($query_all,20);
//new Page('统计记录个数语句',每页记录个数)
if(empty($query_page))
$query_sql = "select * from user";
//注意这里的变量名必须为 $query_sql $query_page ,因为下一页的连接参数默认为 query_sql query_page
$list = $page_object->ListPage($query_sql,$query_page);
//ListPage('没有limit的前一部分,系统自动根据补齐',察看的页数)
$page_object->Parameter = '&action=view';
//这是传送的Url 所带的其它参数,如果有就修改变量 Parameter ,系统自动将她补在后面
//显示数据
for ($i=0;$i< $page_object->CountPage;$i++)
print $list[$i][ID]."->".$list[$i][UserName]."<br>";
//返回的数据为二维哈西(关联)数组,一维为纪录的标识ID号,二维为哈西(关联)数组,取值标识建议采取用数据库中字段名的方法,例如:$list[0][UserName]。
//显示其他相关数据
echo $page_object->CountAll;//纪录总数
echo $page_object->CountPage;//每页显示数据个数
echo $page_object->Link;//显示完整的分页信息
echo $page_object->FirstPage;//第一页
echo $page_object->NextPage;//下一页
echo $page_object->ForPage;//上一页
echo $page_object->LastPage;//最后一页
echo $page_object->CurrPage;//第几页
echo $page_object->PageNum;//共有多少页
$mysql->DatabaseClose();
****************/
?>
作者: 2599qiang 发布时间: 2007-04-30
作者: utfqvfhpyygy 发布时间: 2007-05-19
作者: 75168611 发布时间: 2007-05-21
PHP代码:
<?
/*
*
*主要用于设置数据库配置信息
*mysql -h 192.168.88.24 -u root
*
*/
if (!isset($mDbHost))
{
class Config
{
var $mDbHost = "localhost"; //主机
var $mDbUser = "root"; //账户
var $mDbPassword = "passw0rd"; //密码
var $mDbPort = "3306"; //端口
var $mDbDatabase = "vod"; //默认数据库
}
}
?>
作者: 17too 发布时间: 2007-05-27
作者: 千与千寻 发布时间: 2007-05-27
作者: sanler 发布时间: 2007-05-30
PHP代码:
<?php
/*
*
*冷彦辰编写于2006-3-10 主要用于处理翻页
*
*
*/
class Page{
var $CountAll; //共有纪录数
var $CountPage; //每页显示记录数
var $Link; //显示 完整的分页信息
var $ForPage; //上一页
var $NextPage; //下一页
var $FirstPage; //第一页
var $LastPage; //最后一页
var $CurrPage; //第几页
var $PageNum; //共有多少页
var $Parameter; //参数
var $LimitNum; //不是统计全部记录,而是显示部分记录,例如共有100条记录,但是只统计显示前50条
function Page($sql, $num=30){
//初始化,统计记录数
$this->CountPage = $num;
global $mysql;
$sql = base64_decode($sql);
$result = $mysql->Query($sql);
if (0 != $mysql->AffectedRows()){
$row = $mysql->FetchArray($result);
$this->CountAll = $row[0];
}
else{
$this->CountAll = 0;
}
//print "共有 $this->CountAll <br>";
}
function ListPage($sql, $page=0,$sql_all,$other){
//查询,定义变量,获取数据
global $mysql;
//print "sql sql<br>";
if (isset($this->LimitNum) && $this->CountAll > $this->LimitNum){
$this->CountAll = $this->LimitNum;
}//更新总浏览记录数
$sql_src = $sql;
//if ($page > 0){
$sql = base64_decode($sql);
$sql_all = base64_decode($sql_all);
$sql_src = $sql;
//}
//echo $sql;
if (($this->CountAll % $this->CountPage) == 0)//统计共有多少页
$pagecount = (integer)($this->CountAll/$this->CountPage);
else
$pagecount = (integer)($this->CountAll/$this->CountPage)+1;
$this->ageNum = $pagecount;
if ($page > $this->ageNum)//如果页码超过页码总数则设为最大页码
$page = $this->ageNum;
if ($page <= 0)//如果页码小于等于零则将页码设置为1
$page = 1;
if ($this->CountAll == 0)
{
$this->CurrPage = 0;
}else{
$this->CurrPage = $page;
}
$first_start = ($page-1)*$this->CountPage;
$sql = $sql." limit ".$first_start.", ".$this->CountPage;
//print "2sql<br>";
$result = $mysql->Query($sql);
if (0 != $mysql->AffectedRows()){
$i = 0;
while($row = $mysql->FetchArray($result)){
$array[$i] = $row;
//print "name:".$array[$i][Name]."<br>";
$i++;
}
}
$sql = base64_encode($sql_src);
$sql_all = base64_encode($sql_all);
if ($pagecount >1){
if($page == 1){
$nextpage = $page+1;
$forpage = 1;
$this->Link = "<button onClick=\"javascript:location.href='?query_sql=$sql&query_page=$nextpage".$this->Parameter."&sql_all=".$sql_all."".$other."'\" class=\"button_a\" style=\"width:30;height:22\";><img src=\"images/next.gif\" align=\"absmiddle\"> </button><button onClick=\"javascript:location.href='?query_sql=$sql&query_page=$pagecount".$this->Parameter."&sql_all=".$sql_all."".$other."'\" class=\"button_a\" style=\"width:30;height:22\";><img src=\"images/prev_end.gif\" align=\"absmiddle\"> </button>";
$this->NextPage = "<button onClick=\"javascript:location.href='?query_sql=$sql&query_page=$nextpage".$this->Parameter."&sql_all=".$sql_all."".$other."'\" class=\"button_a\" style=\"width:30;height:22\";><img src=\"images/next.gif\" align=\"absmiddle\"> </button>";
$this->LastPage = "<button onClick=\"javascript:location.href='?query_sql=$sql&query_page=$pagecount".$this->Parameter."&sql_all=".$sql_all."".$other."'\" class=\"button_a\" style=\"width:30;height:22\";><img src=\"images/prev_end.gif\" align=\"absmiddle\"> </button>";
}
else if(($page > 1)&&($page < $pagecount)) {
$forpage = $page-1;
$nextpage = $page+1;
$this->Link = "<button onClick=\"javascript:location.href='?query_sql=$sql&query_page=1".$this->Parameter."&sql_all=".$sql_all."".$other."'\" class=\"button_a\" style=\"width:30;height:22\";><img src=\"images/prev_top.gif\" align=\"absmiddle\"> </button><button onClick=\"javascript:location.href='?query_sql=$sql&query_page=$forpage".$this->Parameter."&sql_all=".$sql_all."".$other."'\" class=\"button_a\" style=\"width:30;height:22\";><img src=\"images/prev.gif\" align=\"absmiddle\"> </button><button onClick=\"javascript:location.href='?query_sql=$sql&query_page=$nextpage".$this->Parameter."&sql_all=".$sql_all."".$other."'\" class=\"button_a\" style=\"width:30;height:22\";><img src=\"images/next.gif\" align=\"absmiddle\"> </button><button onClick=\"javascript:location.href='?query_sql=$sql&query_page=$pagecount".$this->Parameter."&sql_all=".$sql_all."".$other."'\" class=\"button_a\" style=\"width:30;height:22\";><img src=\"images/prev_end.gif\" align=\"absmiddle\"> </button>";
$this->ForPage = "<button onClick=\"javascript:location.href='?query_sql=$sql&query_page=$forpage".$this->Parameter."&sql_all=".$sql_all."".$other."'\" class=\"button_a\" style=\"width:30;height:22\";><img src=\"images/prev.gif\" align=\"absmiddle\"> </button>";
$this->NextPage = "<button onClick=\"javascript:location.href='?query_sql=$sql&query_page=$nextpage".$this->Parameter."&sql_all=".$sql_all."".$other."'\" class=\"button_a\" style=\"width:30;height:22\";><img src=\"images/next.gif\" align=\"absmiddle\"> </button>";
$this->FirstPage = "<button onClick=\"javascript:location.href='?query_sql=$sql&query_page=1".$this->Parameter."&sql_all=".$sql_all."".$other."'\" class=\"button_a\" style=\"width:30;height:22\";><img src=\"images/prev_top.gif\" align=\"absmiddle\"> </button>";
$this->LastPage = "<button onClick=\"javascript:location.href='?query_sql=$sql&query_page=$pagecount".$this->Parameter."&sql_all=".$sql_all."".$other."'\" class=\"button_a\" style=\"width:30;height:22\";><img src=\"images/prev_end.gif\" align=\"absmiddle\"> </button>";
}
else if ($page = $pagecount){
$forpage = $page-1;
$nextpage = 1;
$this->Link = "<button onClick=\"javascript:location.href='?query_sql=$sql&query_page=1".$this->Parameter."&sql_all=".$sql_all."".$other."'\" class=\"button_a\" style=\"width:30;height:22\";><img src=\"images/prev_top.gif\" align=\"absmiddle\"> </button><button onClick=\"javascript:location.href='?query_sql=$sql&query_page=$forpage".$this->Parameter."&sql_all=".$sql_all."".$other."'\" class=\"button_a\" style=\"width:30;height:22\";><img src=\"images/prev.gif\" align=\"absmiddle\"> </button>";
$this->FirstPage = "<button onClick=\"javascript:location.href='?query_sql=$sql&query_page=1".$this->Parameter."&sql_all=".$sql_all."".$other."'\" class=\"button_a\" style=\"width:30;height:22\";><img src=\"images/prev_top.gif\" align=\"absmiddle\"> </button>";
$this->ForPage = "<button onClick=\"javascript:location.href='?query_sql=$sql&query_page=$forpage".$this->Parameter."&sql_all=".$sql_all."".$other."'\" class=\"button_a\" style=\"width:30;height:22\";><img src=\"images/prev.gif\" align=\"absmiddle\"> </button>";
}
}
else{
$this->Link = ' ';
}
return $array;//$array;
}
}
/***************
使用例子
include("class.config.php");
include("class.mysql.php");
include("class.page.php");
global $mysql;
$config = new Config;
$mysql = new TDatabase($config);
$query_all = "select count(*) from user";
$page_object = new Page($query_all,20);
//new Page('统计记录个数语句',每页记录个数)
if(empty($query_page))
$query_sql = "select * from user";
//注意这里的变量名必须为 $query_sql $query_page ,因为下一页的连接参数默认为 query_sql query_page
$list = $page_object->ListPage($query_sql,$query_page);
//ListPage('没有limit的前一部分,系统自动根据补齐',察看的页数)
$page_object->Parameter = '&action=view';
//这是传送的Url 所带的其它参数,如果有就修改变量 Parameter ,系统自动将她补在后面
//显示数据
for ($i=0;$i< $page_object->CountPage;$i++)
print $list[$i][ID]."->".$list[$i][UserName]."<br>";
//返回的数据为二维哈西(关联)数组,一维为纪录的标识ID号,二维为哈西(关联)数组,取值标识建议采取用数据库中字段名的方法,例如list[0][UserName]。
//显示其他相关数据
echo $page_object->CountAll;//纪录总数
echo $page_object->CountPage;//每页显示数据个数
echo $page_object->Link;//显示完整的分页信息
echo $page_object->FirstPage;//第一页
echo $page_object->NextPage;//下一页
echo $page_object->ForPage;//上一页
echo $page_object->LastPage;//最后一页
echo $page_object->CurrPage;//第几页
echo $page_object->PageNum;//共有多少页
$mysql->DatabaseClose();
****************/
?>
作者: xingjia.yang 发布时间: 2007-07-20

作者: embed 发布时间: 2007-07-20

作者: luzhou 发布时间: 2007-07-26
作者: gleon 发布时间: 2007-07-26
作者: luzhou 发布时间: 2007-07-28
热门阅读
-
office 2019专业增强版最新2021版激活秘钥/序列号/激活码推荐 附激活工具
阅读:74
-
如何安装mysql8.0
阅读:31
-
Word快速设置标题样式步骤详解
阅读:28
-
20+道必知必会的Vue面试题(附答案解析)
阅读:37
-
HTML如何制作表单
阅读:22
-
百词斩可以改天数吗?当然可以,4个步骤轻松修改天数!
阅读:31
-
ET文件格式和XLS格式文件之间如何转化?
阅读:24
-
react和vue的区别及优缺点是什么
阅读:121
-
支付宝人脸识别如何关闭?
阅读:21
-
腾讯微云怎么修改照片或视频备份路径?
阅读:28