菜单保存save函数
public
function
save(){
$mid
= (int)input(
'post.mid'
);
$data
[
'pid'
] = (int)input(
'post.pid'
);
$data
[
'title'
] = trim(input(
'post.title'
));
$data
[
'controller'
] = trim(input(
'post.controller'
));
$data
[
'method'
] = trim(input(
'post.method'
));
$data
[
'ord'
] = (int)input(
'post.ord'
);
$data
[
'ishidden'
] = (int)input(
'post.ishidden'
);
$data
[
'status'
] = (int)input(
'post.status'
);
if
(
$data
[
'title'
] ==
''
){
exit
(json_encode(
array
(
'code'
=>1,
'msg'
=>
'菜单名称不能为空'
)));
}
if
(
$data
[
'pid'
]>0 &&
$data
[
'controller'
] ==
''
){
exit
(json_encode(
array
(
'code'
=>1,
'msg'
=>
'控制器名称不能为空'
)));
}
if
(
$data
[
'pid'
]>0 &&
$data
[
'method'
] ==
''
){
exit
(json_encode(
array
(
'code'
=>1,
'msg'
=>
'方法名称不能为空'
)));
}
if
(
$mid
){
$res
=
$this
->db->table(
'admins_menu'
)->where(
array
(
'mid'
=>
$mid
))->update(
$data
);
}
else
{
$res
=
$this
->db->table(
'admins_menu'
)->insert(
$data
);
}
if
(!
$res
){
exit
(json_encode(
array
(
'code'
=>1,
'msg'
=>
'保存失败'
)));
}
exit
(json_encode(
array
(
'code'
=>0,
'msg'
=>
'保存成功'
)));
}