From 5d6d0992fcae945c4e66da822af765de4e289444 Mon Sep 17 00:00:00 2001 From: zyx Date: Thu, 9 May 2019 09:24:09 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E8=87=AA=E5=8A=A8=E5=A4=87?= =?UTF-8?q?=E4=BB=BD=E6=95=B0=E6=8D=AE=E5=BA=93=EF=BC=8C=E6=A0=BC=E5=BC=8F?= =?UTF-8?q?=E9=94=99=E8=AF=AF=E7=9A=84bug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- core/cron/cron_database_backup.php | 22 +++++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-) diff --git a/core/cron/cron_database_backup.php b/core/cron/cron_database_backup.php index 9e809c3..1ca54a9 100644 --- a/core/cron/cron_database_backup.php +++ b/core/cron/cron_database_backup.php @@ -136,14 +136,26 @@ function sqldumptablestruct($table) { } else { return ''; } - $create = $db->fetch_row($createtable); - if(strpos($table, '.') !== FALSE) { + + + $create = $db -> fetch_row($createtable); + + if (strpos($table, '.') !== FALSE) { $tablename = substr($table, strpos($table, '.') + 1); - $create[1] = str_replace("CREATE TABLE $tablename", 'CREATE TABLE '.$table, $create[1]); + $create[1] = str_replace("CREATE TABLE $tablename", 'CREATE TABLE ' . $table, $create[1]); } - $tabledump .= $create[1].";\n"; + $tabledump .= $create[1]; $tablestatus = DB::fetch_first("SHOW TABLE STATUS LIKE '$table'"); - $tabledump .= ($tablestatus['Auto_increment'] ? " AUTO_INCREMENT=$tablestatus[Auto_increment]" : '').";\n\n"; + $tabledump .= (($tablestatus['Auto_increment'] && (strpos($tabledump,'AUTO_INCREMENT')===false))? " AUTO_INCREMENT=$tablestatus[Auto_increment]" : ''). ";\n\n"; + if ($_GET['sqlcompat'] == 'MYSQL40' && $db -> version() >= '4.1' && $db -> version() < '5.1') { + if ($tablestatus['Auto_increment'] <> '') { + $temppos = strpos($tabledump, ','); + $tabledump = substr($tabledump, 0, $temppos) . ' auto_increment' . substr($tabledump, $temppos); + } + if ($tablestatus['Engine'] == 'MEMORY') { + $tabledump = str_replace('TYPE=MEMORY', 'TYPE=HEAP', $tabledump); + } + } return $tabledump; }