public function save() { $method = dhtml($_GET['method']); if (empty($method)) { $this->error('', __URL__); } $DB = new ProjectModel('project'); if (!$DB->create()) { $this->error($DB->getError(), __URL__); } else { $module = "img"; $path = date("Ymd"); $DB->date = time(); switch ($method) { case "add": $pic = $this->_upload($module, $path); $img = $pic[0]['savepath'] . $pic[0]['savename']; $DB->pic = $img; $query = $DB->add(); $this->_jump($query, ""); break; case "edit": if (!empty($_FILES['pic']['name'])) { $pic = $this->_upload($module, $path); $img = $pic[0]['savepath'] . $pic[0]['savename']; $DB->pic = $img; } $query = $DB->save(); $this->_jump($query, "", "edit"); break; } } }
function onadd() { $project = new ProjectModel(); if ($project->add($_POST['name'])) { cpmsg("添加成功", "success", "?m=xing"); } else { cpmsg("添加失败", "error"); } }