时间:2021-05-02
access是不支持limit分页的,想同的关键,问题马上就解决了。
看注释应该很容易理解,access的分页sql从asp json 的google code上来的
<?php/分页类*/class Page{//字段属性public $param; //分页参数public $pagesize; //每页大小public $sql;//当数据库为access,无效public $conn;//设置数据库类型public $dbtype;//当数据库为access配置项public $tbname;//表名public $prikey;//主键//public $url;public function __set($name,$value){$this->$name = $value;}//初始化public function __construct(){//$this->conn=new mysqli("localhost","root","147258","empirecms");//$this->conn->set_charset('utf8');}//销毁public function __destruct(){}//开始public function getStart(){//$param=$this->param;$param=(isset($_GET[$this->param])) ? $_GET[$this->param] : 1;return ($param-1) * $this->pagesize;}//生成SQL语句//mysqlpublic function getMysqlSql(){return $this->sql . " limit " . $this->getStart() ."," .$this->pagesize . "";//return "test";}//access的查询语句,参考json asp googlepublic function getAccessSql(){$end_n=$this->getStart() + $this->pagesize;if($end_n>$this->pagesize){$accsql = "SELECT TOP ". $this->pagesize ." * FROM [" . $this->tbname . "] as a where Not Exists(Select * From (Select Top ". $this->getStart() ." * From [" . $this->tbname . "] order by [" . $this->prikey . "] DESC) b Where b.[" . $this->prikey . "]=a.[" . $this->prikey . "] ) ORDER BY a.[" . $this->prikey . "] DESC" ;}else{$accsql = "SELECT TOP ". $this->pagesize ." * FROM [" . $this->tbname . "] ORDER BY [" . $this->prikey . "] DESC" ;}return $accsql;}//获取记录public function getRecordSet(){switch($this->dbtype){case "ACCESS":$ssql=$this->getAccessSql();break;case "MYSQL":$ssql=$this->getMysqlSql();break;}$rs1=$this->conn->query($ssql);return $rs1;}//获取总页数public function getPageCount(){return $this->getRecordCount() / $this->pagesize;}//获取总记录数public function getRecordCount(){$rs=$this->conn->query("select count(*) from [" .$this->tbname ."]");$row=$rs->fetchColumn();return $row;}//获取分页导航public function getPageTool(){$pagecount= round($this->getPageCount());$param=(isset($_GET[$this->param])) ? $_GET[$this->param] : 1;if($param<=1){echo "首页 上一页 ";}else{echo "<a href='?".$this->param."=1'>首页</a> <a href='?".$this->param."=".($param-1)."'>上一页</A> ";}if($param>=$pagecount){echo "下一页 尾页";}else{echo "<A href='?".$this->param."=".($param+1)."'>下一页</A> <A href='?".$this->param."=".$pagecount."'>尾页</A>";}}}?>本文源自:翔宇亭——IT乐园(http://www.biye5u.com),转载请保留此信息!声明:本页内容来源网络,仅供用户参考;我单位不保证亦不表示资料全面及准确无误,也不保证亦不表示这些资料为最新信息,如因任何原因,本网内容或者用户因倚赖本网内容造成任何损失或损害,我单位将不会负任何法律责任。如涉及版权问题,请提交至online#300.cn邮箱联系删除。
一种是利用php的pdo,一种是odbc,com接口来与access数据库连接。利用pdo与access数据库连接复制代码代码如下:$path="f:font(
1.下载pdo_mysql包wgethttp://pecl.php.net/get/PDO_MYSQL-1.0.2.tgz2.追加编译php,使其module目
本文实例讲述了PHP使用pdo连接access数据库并循环显示数据操作。分享给大家供大家参考,具体如下:PDO连接与查询:try{$conn=newPDO("o
本文实例讲述了PHP使用PDO创建MySQL数据库、表及插入多条数据操作。分享给大家供大家参考,具体如下:创建MySQL数据库:setAttribute(PDO
本文实例讲述了php中mysql操作buffer用法。分享给大家供大家参考。具体分析如下:php与mysql的连接有三种方式,mysql,mysqli,pdo。