From 124966b59db5af4d7eef32e9d2b9137b8e9ede16 Mon Sep 17 00:00:00 2001 From: Anyon Date: Tue, 27 Mar 2018 17:44:47 +0800 Subject: [PATCH] =?UTF-8?q?[=E6=9B=B4=E6=96=B0]=E4=BF=AE=E6=94=B9Db::name?= =?UTF-8?q?=E8=A1=A8=E5=89=8D=E7=BC=80=E9=97=AE=E9=A2=98=20#87?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- extend/controller/BasicAdmin.php | 2 +- extend/service/DataService.php | 12 ++++++------ 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/extend/controller/BasicAdmin.php b/extend/controller/BasicAdmin.php index 8b9d8d454..99ae2835d 100644 --- a/extend/controller/BasicAdmin.php +++ b/extend/controller/BasicAdmin.php @@ -100,7 +100,7 @@ class BasicAdmin extends Controller foreach ($this->request->post() as $key => $value) { if (preg_match('/^_\d{1,}$/', $key) && preg_match('/^\d{1,}$/', $value)) { list($where, $update) = [['id' => trim($key, '_')], ['sort' => $value]]; - if (false === Db::name($db->getTable())->where($where)->update($update)) { + if (false === Db::table($db->getTable())->where($where)->update($update)) { $this->error('列表排序失败, 请稍候再试'); } } diff --git a/extend/service/DataService.php b/extend/service/DataService.php index 43e6c6622..8f974d918 100644 --- a/extend/service/DataService.php +++ b/extend/service/DataService.php @@ -77,10 +77,10 @@ class DataService { $db = is_string($dbQuery) ? Db::name($dbQuery) : $dbQuery; $where[] = [$key, 'eq', isset($data[$key]) ? $data[$key] : '']; - if (Db::name($db->getTable())->where($where)->count() > 0) { - return Db::name($db->getTable())->strict(false)->where($where)->update($data) !== false; + if (Db::table($db->getTable())->where($where)->count() > 0) { + return Db::table($db->getTable())->strict(false)->where($where)->update($data) !== false; } - return Db::name($db->getTable())->strict(false)->insert($data) !== false; + return Db::table($db->getTable())->strict(false)->insert($data) !== false; } /** @@ -101,12 +101,12 @@ class DataService // 删除模式,如果存在 is_deleted 字段使用软删除 if ($field === 'delete') { if (method_exists($db, 'getTableFields') && in_array('is_deleted', $db->getTableFields())) { - return Db::name($table)->where($where)->update(['is_deleted' => '1']) !== false; + return Db::table($table)->where($where)->update(['is_deleted' => '1']) !== false; } - return Db::name($table)->where($where)->delete() !== false; + return Db::table($table)->where($where)->delete() !== false; } // 更新模式,更新指定字段内容 - return Db::name($table)->where($where)->update([$field => $value]) !== false; + return Db::table($table)->where($where)->update([$field => $value]) !== false; } }