2015-10-06 20:25:13 +08:00
|
|
|
<?php
|
|
|
|
|
namespace Admin\Controller;
|
|
|
|
|
use Admin\Controller;
|
2016-01-24 11:54:16 +08:00
|
|
|
|
|
|
|
|
/**
|
2017-02-03 12:32:57 +08:00
|
|
|
* @Author: Zhou Yuyang <1009465756@qq.com> 10:28 2017/02/02
|
2016-12-03 21:42:04 +08:00
|
|
|
* @Copyright 2015-2020 SISMO
|
|
|
|
|
* @Project homepage https://github.com/CNSISMO
|
2017-02-03 12:32:57 +08:00
|
|
|
* @Version 2.0
|
2016-01-24 11:54:16 +08:00
|
|
|
*/
|
|
|
|
|
|
2017-02-03 12:32:57 +08:00
|
|
|
|
2015-10-06 20:25:13 +08:00
|
|
|
/**
|
|
|
|
|
* 单页管理
|
|
|
|
|
*/
|
|
|
|
|
class InfoController extends BaseController
|
|
|
|
|
{
|
|
|
|
|
/**
|
|
|
|
|
* 单页列表
|
|
|
|
|
* @return [type] [description]
|
|
|
|
|
*/
|
|
|
|
|
public function index($key="")
|
|
|
|
|
{
|
|
|
|
|
if($key == ""){
|
|
|
|
|
$model = M('info');
|
|
|
|
|
}else{
|
|
|
|
|
$where['title'] = array('like',"%$key%");
|
|
|
|
|
$where['name'] = array('like',"%$key%");
|
|
|
|
|
$where['_logic'] = 'or';
|
|
|
|
|
$model = M('info')->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('user_id DESC')->select();
|
|
|
|
|
$this->assign('model', $pages);
|
|
|
|
|
$this->assign('page',$show);
|
|
|
|
|
$this->display();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function delete()
|
|
|
|
|
{
|
|
|
|
|
$id = I('get.id',0,'intval');
|
|
|
|
|
$model = M('info');
|
|
|
|
|
$result = $model->where("user_id=".$id)->delete();
|
|
|
|
|
if($result){
|
|
|
|
|
$this->success("删除成功", U('info/index'));
|
|
|
|
|
}else{
|
|
|
|
|
$this->error("删除失败");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|