public function update() { $messageDB = new MessageModelDB(); $updateArr = array(); $whereArr = array(); $whereArr['id'] = $_GET['id']; $sql = "SELECT * FROM `" . $messageDB->getTableName() . "` WHERE `id` = ?"; $row = $messageDB->getRow($sql, array_values($whereArr)); $fieldArr = $messageDB->getFields(); foreach ($fieldArr as $v) { if (in_array($v, array('id'))) { continue; } //跳过主键 if ($_POST[$v] !== null) { $updateArr[$v] = $_POST[$v]; } } $rs = $messageDB->update($updateArr, $whereArr); //获取被修改数据写入日志 $changeOldRow = array_diff_assoc(array_diff_assoc($row, $updateArr), array_diff_key($row, $updateArr)); Log::write($this->adminUserName, $this->ip, $_GET['id'], self::$state . "__" . self::$action, $rs, Log::arrayToLog($changeOldRow)); //获取更改自动更新列表 $changeNewRow = array_diff_assoc($updateArr, $row); if (isset($changeNewRow['pid'])) { $changeNewRow['pid'] = MessageModel::getProject($changeNewRow['pid']); } if (isset($changeNewRow['sub_mid'])) { $changeNewRow['sub_mid'] = MessageModel::getSubmodule($changeNewRow['sub_mid']); } $rs ? Message::showSucc('更新成功', $changeNewRow) : Message::showError('更新失败:' . implode(" ", $messageDB->getErrorInfo())); }