Ejemplo n.º 1
0
    simple_query("CREATE TABLE IF NOT EXISTS `version` (`id` INT AUTO_INCREMENT PRIMARY KEY, `applied_script` VARCHAR(127) UNIQUE)");
}
echo "DB updater started\n";
$factory = new GlobalFactory();
$connection = $factory->getEntityManager()->getConnection();
$host = $connection->getHost();
$user = $connection->getUsername();
$password = $connection->getPassword();
$database = $connection->getDatabase();
$scriptPath = PROJECT_ROOT . 'database/updates';
echo "host: {$host}", PHP_EOL, "user: {$user}", PHP_EOL, "database: {$database}", PHP_EOL;
echo "connect to db...\n";
$link = mysql_connect($host, $user, $password);
mysql_select_db($database, $link);
echo "create version table\n";
create_version();
echo "get actual version\n";
$result = simple_query("select id, applied_script from version");
$applied = array();
foreach ($result as $row) {
    $applied[$row['applied_script']] = $row['id'];
}
echo "scan dir {$scriptPath}\n";
$files = scandir($scriptPath);
$toApply = array();
foreach ($files as $file) {
    if (is_dir($file)) {
        echo "{$file} skipped because it is dir.\n";
        continue;
    }
    if (strrpos($file, ".sql") != strlen($file) - 4) {
Ejemplo n.º 2
0
<?php

##################################
# create_version table				#
##################################
if (!create_version($db)) {
    echo "<tr>\n\n\t\t\t\t\t<td>CREATE TABLE IF NOT EXISTS " . PRFX . "VERSION</td>\n\n\t\t\t\t\t<td><font color=\"red\"><b>Failed </b> </font> " . $db->ErrorMsg() . "</td>\n\n\t\t\t</tr>\n";
    $error_flag = true;
} else {
    echo "<tr>\n\n\t\t\t\t\t<td>CREATE TABLE IF NOT EXISTS " . PRFX . "VERSION</td>\n\n\t\t\t\t\t<td><font color=\"green\"><b>OK</b></font></td>\n\n\t\t\t<tr>\n";
}
##################################
# create_billing_options				#
##################################
if (!create_billing_options($db)) {
    echo "<tr>\n\n\t\t\t\t\t<td>CREATE TABLE IF NOT EXISTS " . PRFX . "BILLING_OPTIONS</td>\n\n\t\t\t\t\t<td><font color=\"red\"><b>Failed </b> </font> " . $db->ErrorMsg() . "</td>\n\n\t\t\t</tr>\n";
    $error_flag = true;
} else {
    echo "<tr>\n\n\t\t\t\t\t<td>CREATE TABLE IF NOT EXISTS " . PRFX . "BILLING_OPTIONS</td>\n\n\t\t\t\t\t<td><font color=\"green\"><b>OK</b></font></td>\n\n\t\t\t<tr>\n";
}
##################################
# create_config_cc_cards				#
##################################
if (!create_config_cc_cards($db)) {
    echo "<tr>\n\n\t\t\t\t<td>CREATE TABLE IF NOT EXISTS " . PRFX . "CONFIG_CC_CARDS</td>\n\n\t\t\t\t<td><font color=\"red\"><b>Failed</b></font> " . $db->ErrorMsg() . "</td>\n\n\t\t\t</tr>\n";
    $error_flag = true;
} else {
    echo "<tr>\n\n\t\t\t<td>CREATE TABLE IF NOT EXISTS " . PRFX . "CONFIG_CC_CARDS</td>\n\n\t\t\t<td><font color=\"green\"><b>OK</b></font></td>\n\n\t\t</tr>\n";
}
##################################
# create_config_work_order_status	#