Fix pgsql reset id error (#1369)

This commit is contained in:
沈唁 2022-04-02 21:27:31 +08:00 committed by GitHub
parent 7ebfe82de1
commit c78f7fda68
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -189,7 +189,12 @@ class Backup extends BaseOptions implements ActionInterface
if (!empty($_FILES)) {
$file = array_pop($_FILES);
if (0 == $file['error'] && is_uploaded_file($file['tmp_name'])) {
if(UPLOAD_ERR_NO_FILE == $file['error']) {
Notice::alloc()->set(_t('没有选择任何备份文件'), 'error');
$this->response->goBack();
}
if (UPLOAD_ERR_OK == $file['error'] && is_uploaded_file($file['tmp_name'])) {
$path = $file['tmp_name'];
} else {
Notice::alloc()->set(_t('备份文件上传失败'), 'error');
@ -270,7 +275,7 @@ class Backup extends BaseOptions implements ActionInterface
}
// 针对PGSQL重置计数
if (false !== strpos($this->db->getVersion(), 'pgsql')) {
if (false !== strpos(strtolower($this->db->getAdapterName()), 'pgsql')) {
foreach ($this->lastIds as $table => $id) {
$seq = $this->db->getPrefix() . $table . '_seq';
$this->db->query('ALTER SEQUENCE ' . $seq . ' RESTART WITH ' . ($id + 1));