public function infos(){
$where['xid'] = $this->_get('id');
$where['token'] = $this->_get('token');
if(IS_POST){
$key = $this->_post('searchkey');
if(empty($key)){
$this->error("关键词不能为空");
}
$where['name|content'] = array('like',"%$key%");
$list = M('Zhufu')->where($where)->order('time DESC')->select();
$count = M('Zhufu')->where($where)->count();
$Page = new Page($count,20);
$show = $Page->show();
$this->assign('key',$key);
}else {
$count = M('Zhufu')->where($where)->count();
$Page = new Page($count,20);
$show = $Page->show();
$list=M('Zhufu')->where($where)->order('time DESC')->select();
}
$this->assign('list',$list);
$this->assign('page',$show);
$this->display();
}
public function delinfos(){
if($this->_get('token')!=$this->token){$this->error('非法操作');}
$id = intval($this->_get('id'));
if(IS_GET){
$where=array('id'=>$id,'token'=>$this->token);
$check=M('Zhufu')->where($where)->find();
if($check==false) $this->error('非法操作');
$back=M('Zhufu')->where($where)->delete();
if($back==true){
$this->success('操作成功',U('Xitie/infos',array('token'=>$this->token,'id'=>$check['xid'])));
}else{
$this->error('服务器繁忙,请稍后再试',U('Xitie/infos',array('token'=>$this->token,'id'=>$check['xid'])));
}
}
}
public function inputs(){
$where['xid'] = $this->_get('id');
$where['token'] = $this->_get('token');
if(IS_POST){
$key = $this->_post('searchkey');
if(empty($key)){
$this->error("关键词不能为空");
}
$where['name'] = array('like',"%$key%");
$list = M('Canyu')->where($where)->order('time DESC')->select();
$count = M('Canyu')->where($where)->count();
$Page = new Page($count,20);
$show = $Page->show();
$this->assign('key',$key);
}else {
$count = M('Canyu')->where($where)->count();
$Page = new Page($count,20);
$show = $Page->show();
$list=M('Canyu')->where($where)->order('time DESC')->select();
}
$num = 0;
foreach($list as $key=>$val){
$num += $val['number'];
}
$this->assign('num',$num);
$this->assign('list',$list);
$this->assign('page',$show);
$this->display();
}
} 最佳答案