Using PHP to copy tables from one Mysql DB to another
I'm trying to write a script that will copy the contents of my development domain over to the live site, or vice versa. Part of this script will also need to copy Mysql tables from one database to another. I have tried doing this manually with PHP (by copying all of the contents of the tables into a PHP array but it runs out of memory very quickly), so I was trying to find a better way of doing this and came across this: http://www.edmondscommerce.co.uk/mys...se-to-another/
This seems really easy, however I don't quite understand how this command can run as PHP will only be logged into one database at a time and the dev database, and the live database have different user/passwords.
DROP TABLE IF EXISTS `backup_db.backup_table`;
CREATE TABLE `backup_db.backup_table` SELECT * FROM `live_db.live_table`
Should I just run the SQL command using the system() function?