第26次PHP作业--TP增删改查

来源:转载

<?php
namespace Admin/Controller;
use Think/Controller;
class UserController extends Controller{
    public function _initialize() {
        //判断是否登录,没有登录跳转到登录页面
        if (empty($_SESSION['adminName'])) {
            $this->error('请先登录', U('Login/login'));
        }
    }
     public function userlist() {
           if(empty($_SESSION["adminName"])){
           $this->redirect('Login/login');
            exit();
        }
        $User = M('user');

        $count = $User->count();
        $Page = new /Think/Page($count, 6);
        foreach($map as $key=>$val) {    $Page->parameter   .=   "$key=".urlencode($val).'&';}
        $show = $Page->show();
        $list = $User->order('uid desc')->limit($Page->firstRow . ',' . $Page->listRows)->select();
        $this->assign('page', $show);
        $this->assign('list', $list);
        $this->display();
    }
     public function alter(){
                   
     }
     public function delete(){
         $del=$_GET['uid'];
        
       $id=  M('user')->where("uid=$del")->delete();
       if($id>0){             
       $this->success('删除成功',U('User/userlist'),3);
     }else{
         $this->error('系统繁忙');
     }
     }
     public function select(){
         
         $data['username']=array('like',I('get.name').'%');
         $row=M('user')->where($data)->select();
         $_SESSION['row']=$row;
         $this->assign('list',$row);
         $this->display('User/userlist');
     }
}

分享给朋友:
您可能感兴趣的文章:
随机阅读: