php to compare structure of mysql tables

Questions about the MySQL, PostgreSQL, and most other databases, as well as using it with PHP can be asked here.

Moderator: General Moderators

Post Reply
mottwsc
Forum Commoner
Posts: 55
Joined: Sun Dec 23, 2007 8:01 pm

php to compare structure of mysql tables

Post by mottwsc »

I'm trying to compare the structure of two mysql tables using php to determine if there are differences in the structures and then output where there are differences. I heard that there is a diff function, but I don't know how to access that via php. Can anyone provide guidance or code samples to help?

Thank you.
User avatar
Benjamin
Site Administrator
Posts: 6935
Joined: Sun May 19, 2002 10:24 pm

Re: php to compare structure of mysql tables

Post by Benjamin »

Essentially you would want to load the details of each table into an array and iterate through them or use PHPs built in array diff functions.

It sounds like you ought to have the secondary server setup as a slave server though, updated by the master automatically.
Post Reply