From 081d31a56e61ca41eb3afe17dbda31e825ad4b8a Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sun, 3 Dec 2017 11:45:34 +0100 Subject: [PATCH] Debug php backup for new mysql version --- htdocs/admin/tools/dolibarr_export.php | 6 +++++- htdocs/admin/tools/export.php | 15 +++++++++++---- 2 files changed, 16 insertions(+), 5 deletions(-) diff --git a/htdocs/admin/tools/dolibarr_export.php b/htdocs/admin/tools/dolibarr_export.php index f61f046254d..7b2c8805f55 100644 --- a/htdocs/admin/tools/dolibarr_export.php +++ b/htdocs/admin/tools/dolibarr_export.php @@ -214,10 +214,13 @@ print ''; + global->MYSQL_OLD_OPTION_DISABLE_FK)) { ?>
+ + +
diff --git a/htdocs/admin/tools/export.php b/htdocs/admin/tools/export.php index 018605d4872..01ab314df73 100644 --- a/htdocs/admin/tools/export.php +++ b/htdocs/admin/tools/export.php @@ -254,7 +254,7 @@ function backup_tables($outputfile, $tables='*') global $errormsg; // Set to UTF-8 - if(is_a($db, 'DoliDBMysqli')) { + if (is_a($db, 'DoliDBMysqli')) { /** @var DoliDBMysqli $db */ $db->db->set_charset('utf8'); } else { @@ -300,11 +300,17 @@ function backup_tables($outputfile, $tables='*') /*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */; /*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */; /*!40101 SET NAMES utf8 */; +/*!40103 SET @OLD_TIME_ZONE=@@TIME_ZONE */; +/*!40103 SET TIME_ZONE='+00:00' */; +/*!40014 SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0 */; +/*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */; +/*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */; +/*!40111 SET @OLD_SQL_NOTES=@@SQL_NOTES, SQL_NOTES=0 */; "; if (GETPOST("nobin_disable_fk")) $sqlhead .= "SET FOREIGN_KEY_CHECKS=0;\n"; - $sqlhead .= "SET SQL_MODE=\"NO_AUTO_VALUE_ON_ZERO\";\n"; + //$sqlhead .= "SET SQL_MODE=\"NO_AUTO_VALUE_ON_ZERO\";\n"; if (GETPOST("nobin_use_transaction")) $sqlhead .= "SET AUTOCOMMIT=0;\nSTART TRANSACTION;\n"; fwrite($handle, $sqlhead); @@ -321,8 +327,8 @@ function backup_tables($outputfile, $tables='*') fwrite($handle, "\n--\n-- Table structure for table `".$table."`\n--\n"); if (GETPOST("nobin_drop")) fwrite($handle,"DROP TABLE IF EXISTS `".$table."`;\n"); // Dropping table if exists prior to re create it - //fwrite($handle,"/*!40101 SET @saved_cs_client = @@character_set_client */;\n"); - //fwrite($handle,"/*!40101 SET character_set_client = utf8 */;\n"); + fwrite($handle,"/*!40101 SET @saved_cs_client = @@character_set_client */;\n"); + fwrite($handle,"/*!40101 SET character_set_client = utf8 */;\n"); $resqldrop=$db->query('SHOW CREATE TABLE '.$table); $row2 = $db->fetch_row($resqldrop); if (empty($row2[1])) @@ -338,6 +344,7 @@ function backup_tables($outputfile, $tables='*') fwrite($handle, "\n--\n-- Dumping data for table `".$table."`\n--\n"); if (!GETPOST("nobin_nolocks")) fwrite($handle, "LOCK TABLES `".$table."` WRITE;\n"); // Lock the table before inserting data (when the data will be imported back) if (GETPOST("nobin_disable_fk")) fwrite($handle, "ALTER TABLE `".$table."` DISABLE KEYS;\n"); + else fwrite($handle, "/*!40000 ALTER TABLE `".$table."` DISABLE KEYS */;\n"); $sql='SELECT * FROM '.$table; $result = $db->query($sql);