Merhaba ben başka bir sunucusu üzerinden veritabanı tablo kopyalayabilirsiniz, ancak her tablonun rekor başka bir db sunucudan tablolar ve her kaydı kopyalayabilirsiniz bir işlevi yazmak nasıl kopya vermedi bir kod yazmak var?
İşte benim örnek kod:
<?php
$dbNewDB = 'newdb';
$dbNewUser = 'newroot';
$dbNewUserPswd = 'newpass';
$dbConnect = mysql_connect('localhost', 'root', 'mypassword') or die('Couldn\'t connect to MySql:'.mysql_error());
$dbNewConnect = mysql_connect('localhost', $dbNewUser, $dbNewUserPswd) or die('Couldn\'t connect to MySql:'.mysql_error());
$sqlStatement = "SHOW TABLES FROM olddb";
$result = mysql_query($sqlStatement,$dbConnect) or die('Unable to get tables: '.mysql_error());
while($row = mysql_fetch_row($result))
{
//Drop table if exist
$sqlStatement = "DROP TABLE IF EXISTS " . $dbNewDB . "." . $row[0];
mysql_query($sqlStatement,$dbNewConnect) or die("Failed to delete: " . mysql_error());
//Create new table
$sqlStatement = "CREATE TABLE " . $dbNewDB . "." . $row[0] . " LIKE olddb." . $row[0];
echo "$sqlStatement [" . __METHOD__ . "]";
mysql_query($sqlStatement,$dbNewConnect)or die("Failed to create: ". mysql_error());
//Insert data
$sqlStatement = "INSERT INTO " . $dbNewDB . "." . $row[0] . " SELECT * FROM " . $dbNewDB . "." . $row[0];
echo "$sqlStatement [" . __METHOD__ . "]";
mysql_query($sqlStatement,$dbNewConnect)or die("Table copy failed: ".mysql_error());
echo "$row[0] copy done. [" . __METHOD__ . "]";
}
mysql_free_result($result);
mysql_close($dbConnect);
mysql_close($dbNewConnect);
?>
my code is already functional All i want to fixed to copy the records of each tables. Any idea?or help?
Teşekkür ederiz!