Ejemplo n.º 1
0
        echo '<p>You already have updated! Please delete this /install folder.<br /><br />
				To force the update to run again, click: <a href="update.php?force">update.php?force</a></p>';
        Template::Show('footer');
        exit;
    }
}
/** 
 * Run a sql file
 */
// Do the queries:
echo 'Starting the update...<br />';
# Do updates based on version
#	But cascade the updates
$CURRENT_VERSION = intval(str_replace('.', '', $CURRENT_VERSION));
$latestversion = intval(str_replace('.', '', UPDATE_VERSION));
$mysqlDiff = new MySQLDiff(array('dbuser' => DBASE_USER, 'dbpass' => DBASE_PASS, 'dbname' => DBASE_NAME, 'dbhost' => DBASE_SERVER, 'dumpxml' => 'sql/structure.xml'));
$diffs_done = $mysqlDiff->getSQLDiffs();
if (!is_array($diffs_done)) {
    $diffs_done = array();
}
# Run it local so it's logged
foreach ($diffs_done as $sql) {
    DB::query($sql);
}
/* Run the update fixtures file */
echo '<h2>Populating Update Data...</h2>';
$sqlLines = Installer::readSQLFile(SITE_ROOT . '/install/fixtures/update.sql', TABLE_PREFIX);
foreach ($sqlLines as $sql) {
    DB::query($sql['sql']);
    if (DB::errno() != 0 && DB::errno() != 1062) {
        echo '<div id="error" style="text-align: left;">Writing to "' . $sql['table'] . '" table... ';
Ejemplo n.º 2
0
<?php

error_reporting(E_ALL);
ini_set('display_errors', 'on');
define('SITE_ROOT', dirname(dirname(dirname(__FILE__))));
include SITE_ROOT . '/core/codon.config.php';
include SITE_ROOT . '/core/lib/mysqldiff/MySQLDiff.class.php';
$params = array('dbuser' => DBASE_USER, 'dbpass' => DBASE_PASS, 'dbname' => DBASE_NAME, 'dbhost' => DBASE_SERVER, 'dumpxml' => SITE_ROOT . '/install/sql/structure.xml');
echo '<pre>';
try {
    $diff = new MySQLDiff($params);
} catch (Exception $e) {
    echo $e->getMessage();
}
try {
    $diff_lines = $diff->getDiffs();
} catch (Exception $e) {
    echo $e->getMessage();
}
var_dump($diff_lines);
# This returns an array of what's missing in the database
try {
    $diff_lines = $diff->getSQLDiffs();
} catch (Exception $e) {
    echo $e->getMessage();
}
print_r($diff_lines);