From 8a98d585a2b1cb3e11b89a7e88a36a16b8c1976b Mon Sep 17 00:00:00 2001 From: JaguarJack <82664165@qq.com> Date: Fri, 18 Jan 2019 14:33:54 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E6=95=B0=E6=8D=AE=E5=AD=97?= =?UTF-8?q?=E5=85=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- application/admin/controller/Database.php | 63 +++++++++++++++++++++++ application/model/LogRecordModel.php | 4 +- views/admin/database/index.html | 63 +++++++++++++++++++++++ views/admin/database/view.html | 30 +++++++++++ 4 files changed, 158 insertions(+), 2 deletions(-) create mode 100644 application/admin/controller/Database.php create mode 100644 views/admin/database/index.html create mode 100644 views/admin/database/view.html diff --git a/application/admin/controller/Database.php b/application/admin/controller/Database.php new file mode 100644 index 0000000..aad5291 --- /dev/null +++ b/application/admin/controller/Database.php @@ -0,0 +1,63 @@ +tables = Db::query('SHOW TABLE STATUS'); + + return $this->fetch(); + } + + /** + * 优化表 + * + * @time at 2019年01月18日 + * @return void + */ + public function optimize() + { + $table = $this->request->post('table'); + + if (!$table) { + $this->error('参数错误, 未指定表'); + } + + Db::query(sprintf('optimize table %s', $table)) ? $this->success('优化成功') : $this->error('优化失败'); + + } + + /** + * + * + * @time at 2019年01月18日 + * @return void + */ + public function view() + { + $table = $this->request->param('table'); + + if (!$table) { + $this->error('参数错误', '未指定表'); + } + + $this->table = Db::query('show full columns from ' . $table); + + return $this->fetch(); + } +} \ No newline at end of file diff --git a/application/model/LogRecordModel.php b/application/model/LogRecordModel.php index d26dfb7..fadc25f 100644 --- a/application/model/LogRecordModel.php +++ b/application/model/LogRecordModel.php @@ -24,13 +24,13 @@ class LogRecordModel extends BaseModel public function getAll(array $params, $limit = self::LIMIT) { if (!count($params)) { - return $this->paginate($limit, false, ['query' => request()->param()]); + return $this->order('created_at', 'desc')->paginate($limit, false, ['query' => request()->param()]); } if (isset($params['name'])) { $list = $this->whereLike('user_name', '%'.$params['name'].'%'); } - return $list->paginate($limit, false, ['query' => request()->param()]); + return $list->order('created_at', 'desc')->paginate($limit, false, ['query' => request()->param()]); } } \ No newline at end of file diff --git a/views/admin/database/index.html b/views/admin/database/index.html new file mode 100644 index 0000000..46e6504 --- /dev/null +++ b/views/admin/database/index.html @@ -0,0 +1,63 @@ +{extend name="public:base" /} +{block name="menu"}数据字段{/block} +{block name="table-head"} +