<link rel="stylesheet" type="text/css" href="../css/body.css" /> <style> body {font-size:80%; margin:5px} h1 {font-size:140%} table {margin-left:40px; border-collapse:collapse} td {border:1px solid #C0C0C0; padding:2px} .grey {background-color:#EAEAEA; font-weight:bold} .nonexist {background-color:#FFC0C0} .dkred {background-color:#C00000; color:white; font-weight:bold} .err {color:red; font-weight:bold} </style> </head> <body> <?php if (isset($_POST['submit'])) { make_db_connections(); $table_list = get_tables($_POST['master_dbname'], $master_mysqli); foreach ($table_list as $table) { echo "<h1>{$table}</h1>\n"; compare_tables($_POST['master_dbname'], $_POST['test_dbname'], $table, $master_mysqli, $test_mysqli); } } else { echo display_form(); } ?> </body> </html>
$options['dbpass2'] = empty($options['dbpass2']) ? $options['dbpass1'] : $options['dbpass2']; $options['dbname2'] = empty($options['dbname2']) ? $options['dbname1'] : $options['dbname2']; $options['dbprefix2'] = empty($options['dbprefix2']) ? $options['dbprefix1'] : $options['dbprefix2']; if ($options['help']) { $help = "Compare 2 database schemas, using built-in Moodle facilities\n\nOptions:\n-h, --help Print out this help\n--\n--dblibrary Type of PHP driver used (native, pdo..). Defaults to native\n--dbtype Name of the driver used (mysqli, pqsql...). Defaults to mysqli\n--dbhostX IP/Name of the host. Defaults to localhost, 2nd defaults to 1st\n--dbuserX Login to the database. 2nd defaults to 1st\n--dbpassX Password to the database. 2nd defaults to 1st\n--dbnameX Name of the database. 2nd defaults to 1st\n--dbprefixX Prefix to apply to all DB objects. Defaults to mdl. 2nd defaults to 1st\n\nExample:\n\$sudo -u www-data /usr/bin/php local/ci/compare_databases/compare_databases.php --dbuser1=stronk7 --dbpass1=mojitos --dbname1=dbone --dbname2=dbtwo\n"; echo $help; exit(0); } // Always run the comparison in developer debug mode. $CFG->debug = DEBUG_DEVELOPER; error_reporting($CFG->debug); raise_memory_limit(MEMORY_EXTRA); // Let's connect to both ends $db1 = compare_connect($options['dblibrary'], $options['dbtype'], $options['dbhost1'], $options['dbuser1'], $options['dbpass1'], $options['dbname1'], $options['dbprefix1']); $db2 = compare_connect($options['dblibrary'], $options['dbtype'], $options['dbhost2'], $options['dbuser2'], $options['dbpass2'], $options['dbname2'], $options['dbprefix2']); list($tablesarr, $errorsarr) = compare_tables($db1, $db2); foreach ($tablesarr as $tname => $tinfo) { $errorsarr = array_merge($errorsarr, compare_columns($tname, $tinfo->columns1, $tinfo->columns2)); $errorsarr = array_merge($errorsarr, compare_indexes($tname, $tinfo->indexes1, $tinfo->indexes2)); } // Errors found, print them $nerrors = count($errorsarr); if ($errorsarr) { // Prepare params ksort($options); $paramstxt = ' Parameters: '; foreach ($options as $key => $value) { if ($key == 'dbpass1' || $key == 'dbpass2' || $key == 'help') { continue; } $paramstxt .= "{$key}={$value}, ";