Skip to content

Instantly share code, notes, and snippets.

@nabeelio
Created April 13, 2011 00:50
Show Gist options
  • Save nabeelio/916762 to your computer and use it in GitHub Desktop.
Save nabeelio/916762 to your computer and use it in GitHub Desktop.
Example of how to use the MySQLDiffTool class
<?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