优化安装程序,初试数据库驱动为InnoDb

This commit is contained in:
2020-04-18 20:42:40 +08:00
parent abc1fac1b9
commit b3157054e3
5 changed files with 74 additions and 220 deletions

View File

@@ -141,10 +141,8 @@ class Config extends Base {
*/
public function save($config) {
if ($config && is_array($config)) {
$Config = db('Config');
foreach ($config as $name => $value) {
$map = array('name' => $name);
$Config->where($map)->setField('value', $value);
(new ConfigM())->save(['value' => $value], ['name' => $name]);
}
}
Cache::pull('system_config_data');
@@ -156,14 +154,14 @@ class Config extends Base {
* @author 麦当苗儿 <zuojiazi@vip.qq.com>
*/
public function del() {
$id = array_unique((array) input('id', 0));
$id = $this->request->param('id');
if (empty($id)) {
return $this->error('请选择要操作的数据!');
}
$map = array('id' => array('in', $id));
if (db('Config')->where($map)->delete()) {
$result = ConfigM::find($id)->delete();
if (false !== $result) {
Cache::pull('system_config_data');
return $this->success('删除成功');
} else {
@@ -171,41 +169,6 @@ class Config extends Base {
}
}
/**
* @title 配置排序
* @author huajie <banhuajie@163.com>
*/
public function sort() {
if ($this->request->isGet()) {
$ids = input('ids');
//获取排序的数据
$map = array('status' => array('gt', -1));
if (!empty($ids)) {
$map['id'] = array('in', $ids);
} elseif (input('group')) {
$map['group'] = input('group');
}
$list = db('Config')->where($map)->field('id,title')->order('sort asc,id asc')->select();
$this->assign('list', $list);
$this->setMeta('配置排序');
return $this->fetch();
} elseif ($this->request->isPost()) {
$ids = input('post.ids');
$ids = explode(',', $ids);
foreach ($ids as $key => $value) {
$res = db('Config')->where(array('id' => $value))->setField('sort', $key + 1);
}
if ($res !== false) {
return $this->success('排序成功!', Cookie('__forward__'));
} else {
return $this->error('排序失败!');
}
} else {
return $this->error('非法请求!');
}
}
/**
* @title 主题选择
*/