NYCPHP Meetup

NYPHP.org

[nycphp-talk] mysql sync w/ php

Dan Cech dcech at phpwerx.net
Fri Jan 23 12:02:12 EST 2004


jon baer wrote:
> greetings ...
> 
> im trying to accomplish the same shell in only php without having to use
> shell_exec is it possible?
> 
> mysqldump -h server1 -u user1 -psecret --add-drop-table db table(s) |
> mysql -h server2 -u user2 -psecret db
> 
> - jon

Possible - yes
Easy - no

If I understand you correctly you want to copy a database from one 
server to another using php.

It is going to be much more efficient to use the shell commands than 
trying to go through the mysql extension for php, because it is 
restricted to executing only one sql command at a time, so each query 
would have to be executed separately.

Not to mention you would need to devise some system to read data from 
your source database and convert it into SQL to execute against the 
second database.

I am not sure exactly what the purpose of your script is, but you might 
be able to get some good pointers from checking out the source of 
phpMyAdmin.

Dan




More information about the talk mailing list