2015-07-28 15:15:57 +08:00
|
|
|
|
<?php
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
* @author Zhou Yuyang <1009465756@qq.com> 2015-07-27
|
|
|
|
|
|
* @copyright ©2105-2018 SRCMS
|
|
|
|
|
|
* @homepage http://www.src.pw
|
|
|
|
|
|
* @version 1.0
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
namespace Home\Controller;
|
|
|
|
|
|
|
|
|
|
|
|
use Think\Controller;
|
|
|
|
|
|
|
|
|
|
|
|
class PageController extends Controller{
|
|
|
|
|
|
|
|
|
|
|
|
public function index($key="")
|
|
|
|
|
|
{
|
|
|
|
|
|
if($key == ""){
|
|
|
|
|
|
$model = M('page');
|
|
|
|
|
|
}else{
|
|
|
|
|
|
$where['title'] = array('like',"%$key%");
|
|
|
|
|
|
$where['name'] = array('like',"%$key%");
|
|
|
|
|
|
$where['_logic'] = 'or';
|
|
|
|
|
|
$model = M('page')->where($where);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
$count = $model->where($where)->count();// 查询满足要求的总记录数
|
|
|
|
|
|
$Page = new \Extend\Page($count,15);// 实例化分页类 传入总记录数和每页显示的记录数(25)
|
|
|
|
|
|
$show = $Page->show();// 分页显示输出
|
|
|
|
|
|
$pages = $model->limit($Page->firstRow.','.$Page->listRows)->where($where)->order('id DESC')->select();
|
|
|
|
|
|
$this->assign('model', $pages);
|
|
|
|
|
|
$this->assign('page',$show);
|
|
|
|
|
|
$this->display();
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
2015-07-28 19:00:39 +08:00
|
|
|
|
public function view(){
|
|
|
|
|
|
$id = I('get.id',0,'intval'); //对传入数字参数做整数校验,规避SQLinjection漏洞
|
2015-07-28 15:15:57 +08:00
|
|
|
|
$model = M('page')->where('id='.$id)->find();
|
|
|
|
|
|
$this->assign('model',$model);
|
|
|
|
|
|
$this->display();
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|