Re: How can I use PHP to duplicate a mysql template database? [hack] bug

From: Date: Wed, 18 Dec 2002 19:26:07 +0000
Subject: Re: How can I use PHP to duplicate a mysql template database? [hack] bug
References: 1  Groups: php.db 
Request: Send a blank email to php-db+get-24270@lists.php.net to get a copy of this message
on 12/17/02 6:20 PM, Daevid Vincent at daevid@daevid.com appended the following bits to my mbox: > This method copies the data, but doesn't copy 'Extra' stuff like > "auto_increment". I've used the following before: SHOW CREATE TABLE $tablename You could probably do something like this. 1) Pick the database (SHOW DATABASES); 2) Create new database 3) List the tables in the database (SHOW TABLES FROM $database) 4) For each table in the database, do the following: a) SHOW CREATE TABLE $tablename b) perform the above query on the new database c) transfer the data If the databases are on the same server, I think you can do (c) as the following: INSERT INTO $new_database.$tablename SELECT * FROM $old_database.$tablename; If it's a remote server, I think it would require you to do it in PHP (ouch). Hope that helps. Sincerely, Paul Burney <http://paulburney.com/> <?php while ($self != "asleep") { $sheep_count++; } ?>

« previous php.db (#24270) next »