含有分页的操作

controler中任意位置可以这样写:


$_Obj = M('news');//实例化对象
$_Obj->pageSize = 20;//每页20个

$_Obj->field('id,title');//字段 可选,默认全部字段
$_Obj->orderby('id desc');//排序方式 可选

$_Obj->where("id>10 and id <20");//where过滤 可选

$_Obj->limit(10);//返回十条 可选
$_objAry = $_Obj->getList();//getList方法会返回分页对象 必须

$this->setValue("objAry", $_objAry);//模板中循环这个数组即可
$this->setValue("Obj", $_Obj);//对象

模板中调用:
{:$Obj->pagenav:}
即可


上面也可以这样写:

$_Obj = M('news');
$_Obj->pageSize = 20;

$_objAry = $_Obj->field('id,title')->orderby('id desc')->where("id>10 and id <20")->limit(10)->getList();

$this->setValue("objAry", $_objAry);//模板中循环这个数组即可
$this->setValue("Obj", $_Obj);//对象

(c) CodaCms.
Design & Develop by Coda IntelliSoft