mirror of
https://gitee.com/zoujingli/ThinkAdmin.git
synced 2025-04-05 19:41:44 +08:00
parent
50cc152165
commit
124966b59d
@ -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('列表排序失败, 请稍候再试');
|
||||
}
|
||||
}
|
||||
|
@ -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;
|
||||
}
|
||||
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user