public function update() { $onlineDebugDB = new OnlineDebugModelDB(); $updateArr = array(); $whereArr = array(); $whereArr['id'] = $_GET['id']; $sql = "SELECT * FROM `" . $onlineDebugDB->getTableName() . "` WHERE `id` = ?"; $row = $onlineDebugDB->getRow($sql, array_values($whereArr)); $fieldArr = $onlineDebugDB->getFields(); foreach ($fieldArr as $v) { if (in_array($v, array('id'))) { continue; } //跳过主键 if ($_POST[$v] !== null) { $updateArr[$v] = $_POST[$v]; } } $rs = $onlineDebugDB->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'] = OnlineDebugModel::getProject($changeNewRow['pid']); } $rs ? Message::showSucc('更新成功', $changeNewRow) : Message::showError('更新失败:' . implode(" ", $onlineDebugDB->getErrorInfo())); }