本文实例讲述了php基于SQLite实现的分页功能。分享给大家供大家参考,具体如下:
这里操作数据库文件使用的是前面文章《PHP基于PDO实现的SQLite操作类【包含增删改查及事务等操作】》中的SQLite数据库操作类。废话不说,直接上代码:
class SqlitePage{
public function __construct()
{
$this->table_name='';
$this->tj='';
$this->page_size='';
$this->current_page='';
$this->total_page='';
include_once 'sqlite_db.php';
$this->db=new SqliteDB();//可以调用他的操作方法了
}
function entrance($table_name,$page_size,$tj='')//sql中不包含limit page_size为每页显示条数
{
// 首先获取当前页
// sql = "select * from tab where "+条件+" order by "+排序+" limit "+要显示多少条记录+" offset "+跳过多少条记录;
$this->page_size=$page_size;
$this->table