Created
April 13, 2011 00:50
-
-
Save nabeelio/916762 to your computer and use it in GitHub Desktop.
Example of how to use the MySQLDiffTool class
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 | |
include 'MySQLDiff.class.php'; | |
$params = ; | |
try { | |
$diff = new MySQLDiff(array( | |
'dbuser' => 'testuser', | |
'dbpass' => 'test1', | |
'dbname' => 'testuser', | |
'dbhost' => 'localhost', | |
'dumpxml' => 'structure.xml', | |
) | |
); | |
} catch(Exception $e) { | |
echo $e->getMessage(); exit; | |
} | |
# This returns an array of what's missing in the database | |
try { | |
$diff_lines = $diff->getDiffs(); | |
var_dump($diff_lines); | |
catch(Exception $e) { | |
echo $e->getMessage(); exit; | |
} | |
# This returns SQL queries which can be run to fix the database | |
try { | |
$diff_lines = $diff->getSQLDiffs(); | |
var_dump($diff_lines); | |
} catch(Exception $e) { | |
echo $e->getMessage(); exit; | |
} | |
# This generates the SQL and actually runs all of them | |
try { | |
$diff_lines = $diff->runSQLDiff(); | |
var_dump($diff_lines); | |
} catch(Exception $e) { | |
echo $e->getMessage(); exit; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment