I have to create a clone of database table. I worked with wordpress database and i want to create a clone of WP-options table. How can i create a clone of a particular table in database. I found some code
set_time_limit(0);
$username = 'XXXXXX';
$password = 'YYYYYY';
$hostname = 'ZZZZZZ';
$database = 'AAAAAA';
try {
$pdo = new PDO("mysql:host={$hostname};dbname={$database}", $username, $password);
}
catch(PDOException $e) {
die("Could not connect to the database
");
}
echo '<pre>';
$stmt1 = $pdo->query('SHOW TABLES', PDO::FETCH_NUM);
foreach($stmt1->fetchAll() as $row) {
$stmt2 = $pdo->query("SHOW CREATE TABLE `$row[0]`", PDO::FETCH_ASSOC);
$table = $stmt2->fetch();
echo "{$table['Create Table']};
";
}
echo '</pre>';
But i cant understand how can i get the database in a folder which path i given.