PHP code for comparison of mysql database differences. Of course, you can browse in PHPMYADMIN. But there are omissions after all. So I wrote a script for comparing database differences (for PHP. Of course, the code is very simple. you can go to PHPMYADMIN to view it. But there are omissions after all. So I wrote a script for comparing database differences (for PHP. Of course, the code is very simple and I will not explain it. paste the code:
The code is as follows:
Mysql_connect ('localhost', 'root', 'root ');
Mysql_select_db ('tablea'); // standard database
$ Q = mysql_query ("show tables ");
While ($ s = mysql_fetch_array ($ q )){
$ Name = $ s [0];
$ Q1 = mysql_query ("desc $ name ");
While ($ s1 = mysql_fetch_array ($ q1 )){
$ A [$ name] [] = $ s1 [0];
}
}
Mysql_close ();
Mysql_connect ('localhost', 'root', 'root ');
Mysql_select_db ('tableb'); // the database to be compared
$ Q2 = mysql_query ("show tables ");
While ($ s2 = mysql_fetch_array ($ q2 )){
$ Name2 = $ s2 [0];
$ Q3 = mysql_query ("desc $ name2 ");
While ($ s3 = mysql_fetch_array ($ q3 )){
$ Aa [$ name2] [] = $ s3 [0];
}
}
Mysql_close ();
$ F = $ e = array ();
$ Str = $ fuhao = '';
Foreach ($ a as $ k => $ v ){
If (! Is_array ($ aa [$ k]) {
$ E [] = $ k;
}
Else {
If (count ($ aa [$ k]) <> count ($ v )){
Foreach ($ v as $ k1 => $ v1 ){
If (! In_array ($ v1, $ aa [$ k]) {
$ F [$ k] [] = $ v1;
}
}
}
}
}
Echo"
";
Print_r ($ e); // The table is missing
Print_r ($ f); // The Table field is missing
?>
Bytes. But there are omissions after all. So I wrote a script for comparing database differences (for PHP. Of course, the code is very simple ,...