目录路径:admin\model\demo.php,根据前台$act传递参数不同,进行不同的操作
```
switch ($act) {
//删除演示数据;
case "del";
$vid = get_param('vid');
if (is_array($vid)) {
$vid = implode(",", $vid);
}
if ($vid == '') {
die("vid错误");
}
$db->delete('demo', 'vid in(' . $vid . ')');
//操作日志;
addlogs($_COOKIE["adminname"], $vid . '数据删除,STATUS:OK', '', time(), $_SERVER["REMOTE_ADDR"]);
break;
//编辑单个演示数据;
case "edit";
$vid = $_POST['vid'];
$vname = $_POST['vname'];
$vdata = $_POST['vdata'];
$vtask = $_POST['vtask'];
$vctime = strtotime($_POST['vctime']);
$db->update('demo', array('vname' => $vname, 'vdata' => $vdata, 'vtask' => $vtask, 'vctime' => $vctime), 'vid=' . $vid);
//操作日志;
addlogs($_COOKIE["adminname"], $vid . '数据编辑,STATUS:OK', '', time(), $_SERVER["REMOTE_ADDR"]);
break;
//添加单个演示数据;
case "add";
$vname = $_POST['vname'];
$vdata = $_POST['vdata'];
$vtask = $_POST['vtask'];
$vctime = strtotime($_POST['vctime']);
$db->insert('demo', array('vname' => $vname, 'vdata' => $vdata, 'vtask' => $vtask, 'vctime' => $vctime));
//操作日志;
addlogs($_COOKIE["adminname"], $vname . '数据添加,STATUS:OK', '', time(), $_SERVER["REMOTE_ADDR"]);
break;
//读取单个演示数据;
case "show";
$vid = get_param('vid');
$row = $db->fetch('demo', 'vid,vname,vdata,vtask,vctime', array('vid' => $vid), 'vid asc');
break;
//读取日志列表数据;
default:
$page = get_param('page');
$page = intval($page) == 0 ? 1 : intval($page);
$pagenum = 15;
$startI = $page * $pagenum - $pagenum;
$count = $db->rowcount('demo', '');
$pages = getPages($count, $page, $pagenum);
$row = $db->fetchall('demo', 'vid,vname,vdata,vtask,vctime', '', ' vid DESC', $startI . ',' . $pagenum);
}
```