码迷,mamicode.com
首页 > 数据库 > 详细

thinkphp 原生sql使用分页类

时间:2014-12-30 22:03:18      阅读:275      评论:0      收藏:0      [点我收藏+]

标签:

public function index(){

import("@.ORG.Page");       //导入分页类

$Dao = M();

$count = count($Dao->query("SELECT * FROM ofuser WHERE uid IN (SELECT uid FROM ofid WHERE uid =‘1‘)"));//总计条数

$Page = new Page($count, 10); //一页中的数量为5

$list = $Dao->query("SELECT * FROM ofuser WHERE uid IN (SELECT uid FROM ofid WHERE uid =‘1‘) limit $Page->firstRow,$Page->listRows");//根据上面的条件进行查询

$Page->parameter    =   ‘search=key&name=thinkphp‘;//parameter参数
        // 设置分页显示
$Page->setConfig(‘header‘, ‘条数据‘);//页面显示为:6条数据
        $Page->setConfig(‘first‘, ‘<<‘);
        $Page->setConfig(‘last‘, ‘>>‘);
        $page = $Page->show();
        $this->assign("page", $page);
        $this->assign("list", $list);
        $this->display();
        //dump($list);
        echo $_SESSION[‘uid‘];//显示验证码的SESSION值";
        }

 

thinkphp 原生sql使用分页类

标签:

原文地址:http://www.cnblogs.com/hellowzd/p/4194601.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!