Created
March 10, 2014 09:49
-
-
Save anytizer/9462175 to your computer and use it in GitHub Desktop.
Differences in databases
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
mysql_connect('S.ERV.ER.IP', 'root', 'PASSWORD'); | |
$target='DATABASE_LOCAL'; | |
$source='DATABASE_LIVE'; | |
$schema_listing_sql = " | |
SELECT | |
TABLE_SCHEMA `database`, | |
TABLE_NAME `table`, | |
COLUMN_NAME `column`, | |
COLUMN_TYPE `type` | |
FROM INFORMATION_SCHEMA.COLUMNS | |
WHERE | |
TABLE_SCHEMA IN( | |
'{$target}', | |
'{$source}' | |
) | |
ORDER BY | |
`database`, | |
`table`, | |
`column` | |
;"; | |
$system = array(); | |
$rs = mysql_query($schema_listing_sql); | |
while($row = mysql_fetch_assoc($rs)) | |
{ | |
$system[$row['database']][$row['table']][$row['column']]=$row['type']; | |
} | |
foreach($system[$target] as $table => $column) | |
{ | |
if(isset($system[$target][$table])) | |
{ | |
unset($system[$source][$table]); | |
} | |
} | |
#print_r($system); | |
print_r($system[$source]); | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment