function DB_Copy($source, $destination, $drop_source=0, $insert_data=1) { global $config; if (!isset($config['dbconnection'])) MSD_mysql_connect(); $SQL_Array=$t=""; if (!DB_Exists($destination)) $SQL_Array.="CREATE DATABASE `$destination` ;\n"; $SQL_Array.="USE `$destination` ;\n"; $tabellen=mysql_list_tables($source,$config['dbconnection']); $num_tables=mysql_num_rows($tabellen); for ($i=0; $i < $num_tables; $i++) { $table=mysql_tablename($tabellen,$i); $sqlt="SHOW CREATE TABLE `$source`.`$table`"; $res=MSD_query($sqlt); $row=mysql_fetch_row($res); $c=$row[1]; if (substr($c,-1) == ";") $c=substr($c,0,strlen($c) - 1); $SQL_Array.=( $insert_data == 1 ) ? "$c SELECT * FROM `$source`.`$table` ;\n" : "$c ;\n"; } if ($drop_source == 1) $SQL_Array.="DROP DATABASE `$source` ;"; mysql_select_db($destination); MSD_DoSQL($SQL_Array); }
function DB_Copy($source, $destination, $drop_source = 0, $insert_data = 1) { global $config; if (!isset($config['dbconnection'])) { MSD_mysql_connect(); } $SQL_Array = $t = ""; if (!DB_Exists($destination)) { $SQL_Array .= "CREATE DATABASE `{$destination}` ;\n"; } $SQL_Array .= "USE `{$destination}` ;\n"; $tabellen = mysql_list_tables($source, $config['dbconnection']); $num_tables = mysql_num_rows($tabellen); for ($i = 0; $i < $num_tables; $i++) { $table = mysql_tablename($tabellen, $i); $sqlt = "SHOW CREATE TABLE `{$source}`.`{$table}`"; $res = MSD_query($sqlt) or die(SQLError($sqlt, mysql_error())); $row = mysql_fetch_row($res); $c = $row[1]; if (substr($c, -1) == ";") { $c = substr($c, 0, strlen($c) - 1); } $SQL_Array .= $insert_data == 1 ? "{$c} SELECT * FROM `{$source}`.`{$table}` ;\n" : "{$c} ;\n"; } if ($drop_source == 1) { $SQL_Array .= "DROP DATABASE `{$source}` ;"; } mysql_select_db($destination); MSD_DoSQL($SQL_Array); }
function DB_Copy($source, $destination, $drop_source = 0, $insert_data = 1) { global $config; if (!isset($config['dbconnection'])) { MSD_mysql_connect(); } $SQL_Array = $t = ""; if (!DB_Exists($destination)) { $res = MSD_DoSQL("CREATE DATABASE `{$destination}`;"); if (!$res) { return false; } } $SQL_Array .= "USE `{$destination}` ;\n"; $tabellen = mysqli_query($config['dbconnection'], "SHOW TABLES FROM {$source}"); $num_tables = mysqli_num_rows($tabellen); for ($i = 0; $i < $num_tables; $i++) { $table = mysqli_data_seek($tabellen, $i) && ($___mysqli_tmp = mysqli_fetch_row($tabellen)) !== NULL ? array_shift($___mysqli_tmp) : false; $sqlt = "SHOW CREATE TABLE `{$source}`.`{$table}`"; $res = MSD_query($sqlt); if ($res) { $row = mysqli_fetch_row($res); $c = $row[1]; if (substr($c, -1) == ";") { $c = substr($c, 0, strlen($c) - 1); } $SQL_Array .= $insert_data == 1 ? "{$c} SELECT * FROM `{$source}`.`{$table}` ;\n" : "{$c} ;\n"; } else { return false; } } (bool) mysqli_query($GLOBALS["___mysqli_ston"], "USE " . $destination); $res = MSD_DoSQL($SQL_Array); if ($drop_source == 1 && $res) { MSD_query("DROP DATABASE `{$source}`;"); } return $res; }