MembersController.php
1.3 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
<?php
namespace app\admin\controller;
use cmf\controller\AdminBaseController;
use think\Db;
use app\admin\model\AdminMenuModel;
class MembersController extends AdminBaseController{
//显示会员列表
public function mem_list(){
$data = Db::name('members') -> select();
$this -> assign('data',$data);
return $this -> fetch();
}
//添加会员
public function mem_add(){
$data['name'] = input('post.name');
$data['passwd'] = input('post.passwd');
$data['jifen'] = input('post.jifen');
$id = Db::name('members') -> insertGetId($data);
return $id;
}
//当点击编辑时显示会员数据
public function mem_edit_show(){
$id = input('post.id');
$data = Db::name('members') -> where('id',$id) -> find();
return json_encode($data);
}
//更新数据
public function mem_edit_up(){
$data['id'] = input('post.id');
$data['name'] = input('post.name');
$data['passwd'] = input('post.passed');
$data['jifen'] = input('post.jifen');
$res = Db::name('members') -> update($data);
return true;
}
//删除数据
public function mem_del(){
$id = input('post.id');
Db::name('members') -> delete($id);
return true;
}
}