+
db->server_info."
-SET FOREIGN_KEY_CHECKS=0;
-SET SQL_MODE=\"NO_AUTO_VALUE_ON_ZERO\";
-
/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;
/*!40101 SET NAMES utf8 */;
+
";
+
+ if (GETPOST("nobin_disable_fk")) $sqlhead .= "SET FOREIGN_KEY_CHECKS=0;\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);
+ $ignore = '';
+ if (GETPOST("nobin_sql_ignore")) $ignore = 'IGNORE ';
+ $delayed = '';
+ if (GETPOST("nobin_delayed")) $delayed = 'DELAYED ';
+
// Process each table and print their definition + their datas
foreach($tables as $table)
{
// Saving the table structure
- fwrite($handle, "--\n-- Table structure for table `".$table."`\n--\n\n");
+ fwrite($handle, "\n--\n-- Table structure for table `".$table."`\n--\n");
- //fwrite($handle,"DROP TABLE IF EXISTS `".$table."`;\n"); // Dropping table if exists prior to re create it
+ 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");
$resqldrop=$db->query('SHOW CREATE TABLE '.$table);
@@ -448,18 +456,17 @@ SET SQL_MODE=\"NO_AUTO_VALUE_ON_ZERO\";
// Dumping the data (locking the table and disabling the keys check while doing the process)
- fwrite($handle, "--\n-- Dumping data for table `".$table."`\n--\n\n");
- //fwrite($handle, "LOCK TABLES `".$table."` WRITE;\n"); // Lock the table before inserting data (when the data will be imported back)
- fwrite($handle, "ALTER TABLE `".$table."` DISABLE KEYS;\n");
+ 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");
$sql='SELECT * FROM '.$table;
$result = $db->query($sql);
$num_fields = $db->num_rows($result);
while($row = $db->fetch_row($result)) {
// For each row of data we print a line of INSERT
- fwrite($handle,'INSERT INTO `'.$table.'` VALUES (');
+ fwrite($handle,'INSERT '.$delayed.$ignore.'INTO `'.$table.'` VALUES (');
$columns = count($row);
- $rowsarr = array();
for($j=0; $j<$columns; $j++) {
// Processing each columns of the row to ensure that we correctly save the value (eg: add quotes for string - in fact we add quotes for everything, it's easier)
if ($row[$j] == null and !is_string($row[$j])) {
@@ -479,8 +486,8 @@ SET SQL_MODE=\"NO_AUTO_VALUE_ON_ZERO\";
}
fwrite($handle,implode(',', $row).");\n");
}
- fwrite($handle, "ALTER TABLE `".$table."` ENABLE KEYS;\n"); // Enabling back the keys/index checking
- //fwrite($handle, "UNLOCK TABLES;\n"); // Unlocking the table
+ if (GETPOST("nobin_disable_fk")) fwrite($handle, "ALTER TABLE `".$table."` ENABLE KEYS;\n"); // Enabling back the keys/index checking
+ if (!GETPOST("nobin_nolocks")) fwrite($handle, "UNLOCK TABLES;\n"); // Unlocking the table
fwrite($handle,"\n\n\n");
}
@@ -504,11 +511,10 @@ SET SQL_MODE=\"NO_AUTO_VALUE_ON_ZERO\";
/* Backup Procedure structure*/
// Write the footer (restore the previous database settings)
- $sqlfooter='';
- $sqlfooter.="
-SET FOREIGN_KEY_CHECKS=1;
-
--- Dump completed on ".date('Y-m-d G-i-s');
+ $sqlfooter="\n\n";
+ if (GETPOST("nobin_use_transaction")) $sqlfooter .= "COMMIT;\n";
+ if (GETPOST("nobin_disable_fk")) $sqlfooter .= "SET FOREIGN_KEY_CHECKS=1;\n";
+ $sqlfooter.="\n\n-- Dump completed on ".date('Y-m-d G-i-s');
fwrite($handle, $sqlfooter);
fclose($handle);