鼠笼管理系统
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

33 lines
1.3 KiB

6 months ago
<?php
class Admin_StrainsController extends Ctrl_Admin{
public function indexAction(){
}
public function getlistAction(){
$StrainsModel = new StrainsModel();
$p = $_REQUEST;
$page = $p['page'];
$limit = $p['limit'];
$offset = ($page-1)*$limit;
6 months ago
$sql = "select * from {$StrainsModel->table} ";
6 months ago
$count = $StrainsModel->query($sql);
6 months ago
$sql = "select * from {$StrainsModel->table} order by id desc limit {$offset},{$limit} ";
6 months ago
$data = $StrainsModel->query($sql);
$return['code'] = 0;
$return['count'] = count($count);
$return['data'] = $data;
$return['msg'] = "成功";
echo json_encode($return);die;
}
6 months ago
public function editAction(){
$StrainsModel = new StrainsModel();
$data['id'] = empty($_POST['id'])||!isset($_POST['id'])?Tool_Fnc::apiMsg('系统错误', '500'):Tool_Fnc::safe_string($_POST['id']);
$field = empty($_POST['field'])||!isset($_POST['field'])?Tool_Fnc::apiMsg('系统错误', '500'):Tool_Fnc::safe_string($_POST['field']);
$status = empty($_POST['status'])||!isset($_POST['status'])?0:Tool_Fnc::safe_string($_POST['status']);
$data[$field] = $status;
if(!$StrainsModel->update($data)) Tool_Fnc::ajaxMsg('变更失败', '500');
Tool_Fnc::ajaxMsg('变更成功', '1');
}
6 months ago
}