mirror of
https://gitee.com/zoujingli/ThinkAdmin.git
synced 2025-04-06 03:58:04 +08:00
增加数据清空操作
This commit is contained in:
parent
bcebec04fd
commit
0f95e38167
@ -81,19 +81,13 @@ class Plugs extends Controller
|
|||||||
if (AdminService::instance()->isSuper()) try {
|
if (AdminService::instance()->isSuper()) try {
|
||||||
$this->app->db->transaction(function () {
|
$this->app->db->transaction(function () {
|
||||||
[$tmpdata, $newdata] = [[], []];
|
[$tmpdata, $newdata] = [[], []];
|
||||||
foreach ($this->app->db->name('SystemConfig')->cursor() as $item) {
|
foreach ($this->app->db->name('SystemConfig')->order('type,name asc')->cursor() as $item) {
|
||||||
$tmpdata[$item['type']][$item['name']] = $item['value'];
|
$tmpdata[$item['type']][$item['name']] = $item['value'];
|
||||||
}
|
}
|
||||||
ksort($tmpdata);
|
foreach ($tmpdata as $type => $items) foreach ($items as $name => $value) {
|
||||||
foreach ($tmpdata as $type => $items) {
|
$newdata[] = ['type' => $type, 'name' => $name, 'value' => $value];
|
||||||
ksort($items);
|
|
||||||
foreach ($items as $name => $value) {
|
|
||||||
$newdata[] = ['type' => $type, 'name' => $name, 'value' => $value];
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
$sql = "truncate table {$this->app->db->name('SystemConfig')->getTable()}";
|
$this->_query('SystemConfig')->empty()->insertAll($newdata);
|
||||||
$this->app->db->execute($sql);
|
|
||||||
$this->app->db->name('SystemConfig')->insertAll($newdata);
|
|
||||||
});
|
});
|
||||||
$this->app->cache->delete('SystemConfig');
|
$this->app->cache->delete('SystemConfig');
|
||||||
sysoplog('系统运维管理', '清理系统参数配置成功');
|
sysoplog('系统运维管理', '清理系统参数配置成功');
|
||||||
|
8
vendor/composer/installed.json
vendored
8
vendor/composer/installed.json
vendored
@ -834,12 +834,12 @@
|
|||||||
"source": {
|
"source": {
|
||||||
"type": "git",
|
"type": "git",
|
||||||
"url": "https://github.com/zoujingli/ThinkLibrary.git",
|
"url": "https://github.com/zoujingli/ThinkLibrary.git",
|
||||||
"reference": "fdd8a98cc3538fecdea82378615ac65774100c62"
|
"reference": "9aa8249ae2efa2b5e3fa3cf76c4a7b3c1f61122d"
|
||||||
},
|
},
|
||||||
"dist": {
|
"dist": {
|
||||||
"type": "zip",
|
"type": "zip",
|
||||||
"url": "https://api.github.com/repos/zoujingli/ThinkLibrary/zipball/fdd8a98cc3538fecdea82378615ac65774100c62",
|
"url": "https://api.github.com/repos/zoujingli/ThinkLibrary/zipball/9aa8249ae2efa2b5e3fa3cf76c4a7b3c1f61122d",
|
||||||
"reference": "fdd8a98cc3538fecdea82378615ac65774100c62",
|
"reference": "9aa8249ae2efa2b5e3fa3cf76c4a7b3c1f61122d",
|
||||||
"shasum": "",
|
"shasum": "",
|
||||||
"mirrors": [
|
"mirrors": [
|
||||||
{
|
{
|
||||||
@ -856,7 +856,7 @@
|
|||||||
"ext-mbstring": "*",
|
"ext-mbstring": "*",
|
||||||
"topthink/framework": "^6.0"
|
"topthink/framework": "^6.0"
|
||||||
},
|
},
|
||||||
"time": "2021-03-19T02:16:27+00:00",
|
"time": "2021-03-19T06:30:50+00:00",
|
||||||
"type": "library",
|
"type": "library",
|
||||||
"extra": {
|
"extra": {
|
||||||
"think": {
|
"think": {
|
||||||
|
2
vendor/services.php
vendored
2
vendor/services.php
vendored
@ -1,5 +1,5 @@
|
|||||||
<?php
|
<?php
|
||||||
// This file is automatically generated at:2021-03-19 10:20:45
|
// This file is automatically generated at:2021-03-19 14:37:11
|
||||||
declare (strict_types = 1);
|
declare (strict_types = 1);
|
||||||
return array (
|
return array (
|
||||||
0 => 'think\\admin\\Library',
|
0 => 'think\\admin\\Library',
|
||||||
|
@ -186,6 +186,17 @@ class QueryHelper extends Helper
|
|||||||
return PageHelper::instance()->init($this->query, $page, $display, $total, $limit, $template);
|
return PageHelper::instance()->init($this->query, $page, $display, $total, $limit, $template);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 清空数据并保留表结构
|
||||||
|
* @return $this
|
||||||
|
*/
|
||||||
|
public function empty(): QueryHelper
|
||||||
|
{
|
||||||
|
$table = $this->query->getTable();
|
||||||
|
$this->app->db->execute("truncate table `{$table}`");
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* QueryHelper call.
|
* QueryHelper call.
|
||||||
* @param string $name 调用方法名称
|
* @param string $name 调用方法名称
|
||||||
|
Loading…
x
Reference in New Issue
Block a user