X-Git-Url: https://delta.frontaccounting.com/gitweb/?a=blobdiff_plain;f=admin%2Fdb%2Fmaintenance_db.inc;h=444ac100d2f3cc72b0f32f2827dab98578e9742f;hb=f7d1f5b42d002953b431e140b3625cb5b9549007;hp=840b493b068232282b46ba44b0b10a5f11044a15;hpb=1b77725d52b62a154ef2ea579621ba7a02178996;p=fa-stable.git diff --git a/admin/db/maintenance_db.inc b/admin/db/maintenance_db.inc index 840b493b..444ac100 100644 --- a/admin/db/maintenance_db.inc +++ b/admin/db/maintenance_db.inc @@ -96,7 +96,7 @@ function db_drop_db($connection) // get table structures foreach ($all_tables as $table) { - if (strpos($table['Name'], $connection["tbpref"]) !== false) + if (strpos($table['Name'], $connection["tbpref"]) === 0) db_query("DROP TABLE `".$table['Name'] . "`"); } //deleting the tables, how?? @@ -136,6 +136,12 @@ function db_import($filename, $connection) { $data_queries[] = substr($line, 0, strlen($line) - 1); + // this line does not, too + } + elseif (strtolower(substr($line,0,6)) == "update") + { + $data_queries[] = substr($line, 0, strlen($line) - 1); + // this line does not, too } elseif (strtolower(substr($line, 0, 20)) == "drop table if exists") @@ -149,6 +155,10 @@ function db_import($filename, $connection) $table = true; $table_queries[] = $line . "\n"; } + elseif (strtolower(substr($line, 0, 11)) == "alter table") + { + $data_queries[] = substr($line, 0, strlen($line) - 1); + } // the current line belongs to a create sql query } @@ -156,8 +166,10 @@ function db_import($filename, $connection) { // create sql query ending in this line - if (strtolower(substr($line, 0, 1)) == ")") + if (strtolower(substr($line, 0, 1)) == ")") { $table = false; + $line = substr($line,0,strlen($line)-1); + } $table_queries[count($table_queries) - 1] .= $line . "\n"; } } @@ -202,6 +214,7 @@ function db_import($filename, $connection) { //if ($CONF['import_error']) echo $data_query."\n
".mysql_error()."

\n"; $sql_error = true; + return false; } } } @@ -321,7 +334,9 @@ function db_export($conn, $filename, $zip='no', $comment='') $all_tables = array(); while($row = db_fetch($res)) { - if ($conn["tbpref"] == "" || strpos($row['Name'], $conn["tbpref"]) !== false) + //if ($conn["tbpref"] == "" || strpos($row['Name'], $conn["tbpref"]) !== false) replaced + if (($conn["tbpref"] == "" && !preg_match('/[0-9]+_/', $row['Name'])) || + ($conn["tbpref"] != "" && strpos($row['Name'], $conn["tbpref"]) !== false)) $all_tables[] = $row; } // get table structures @@ -396,11 +411,7 @@ function db_export($conn, $filename, $zip='no', $comment='') // run through each field for ($k = 0; $k < $nf = db_num_fields($res2); $k++) { - // identify null values and save them as null instead of '' - if ($field_type[$k] != "" && $field_type[$k] != "NO" && $row2[$k] == "") - $out .= "NULL"; - else - $out .= "'" . db_escape($row2[$k]) . "'"; + $out .= db_escape($row2[$k]); if ($k < ($nf - 1)) $out .= ", "; } @@ -420,7 +431,7 @@ function db_export($conn, $filename, $zip='no', $comment='') } elseif ($error) { - @unlink($path_to_root . BACKUP_PATH . $backupfile); + @unlink(BACKUP_PATH . $backupfile); return false; } @@ -438,7 +449,7 @@ function db_export($conn, $filename, $zip='no', $comment='') } else { - @unlink($path_to_root . BACKUP_PATH . $backupfile); + @unlink(BACKUP_PATH . $backupfile); return false; } @@ -453,7 +464,7 @@ function db_export($conn, $filename, $zip='no', $comment='') } else { - @unlink($path_to_root . BACKUP_PATH . $backupfile); + @unlink(BACKUP_PATH . $backupfile); return false; } return $backupfile; @@ -516,7 +527,7 @@ function save_to_file($backupfile, $zip, $fileData) if ($zip == "gzip") { - if ($zp = @gzopen($path_to_root . BACKUP_PATH . $backupfile, "a9")) + if ($zp = @gzopen(BACKUP_PATH . $backupfile, "a9")) { @gzwrite($zp, $fileData); @gzclose($zp); @@ -592,7 +603,7 @@ function save_to_file($backupfile, $zip, $fileData) // total # of entries "on this disk", total # of entries overall, size of central dir, offset to start of central dir, .zip file comment length $fileData .= pack('v', 1) . pack('v', 1) . pack('V', strlen($cdrec)) . pack('V', strlen($fr)) . "\x00\x00"; - if ($zp = @fopen($path_to_root . BACKUP_PATH . $backupfile, "a")) + if ($zp = @fopen(BACKUP_PATH . $backupfile, "a")) { @fwrite($zp, $fileData); @fclose($zp); @@ -607,7 +618,7 @@ function save_to_file($backupfile, $zip, $fileData) } else { - if ($zp = @fopen($path_to_root . BACKUP_PATH . $backupfile, "a")) + if ($zp = @fopen(BACKUP_PATH . $backupfile, "a")) { @fwrite($zp, $fileData); @fclose($zp);