Exemplo n.º 1
0
    echo '<script>MoveTables(2)</script>';
} else {
    $strError = "";
    $end_time = time() + 5;
    do {
        $rsTables = $DB->Query("SELECT * FROM b_cluster_table WHERE MODULE_ID = '" . $DB->ForSQL($_REQUEST["module"]) . "' ORDER BY ID", false, '', array("fixed_connection" => true));
        $arTable = $rsTables->Fetch();
        if ($arTable) {
            if (strlen($arTable["LAST_ID"]) <= 0) {
                $strError = CreateNodeTable($nodeDB1, $nodeDB2, $arTable["TABLE_NAME"]);
            }
            if ($strError) {
                echo $strError;
                break;
            }
            $arTable["COLUMNS"] = GetTableColumns($nodeDB1, $arTable["TABLE_NAME"]);
            $i = intval($arTable["REC_COUNT"]);
            $di = 0;
            $last_id = '';
            $strInsert = "";
            if (strlen($arTable["KEY_COLUMN"]) > 0) {
                $strSelect = "\n\t\t\t\t\tSELECT *\n\t\t\t\t\tFROM " . $arTable["TABLE_NAME"] . "\n\t\t\t\t\t" . (strlen($arTable["LAST_ID"]) > 0 ? "WHERE " . $arTable["KEY_COLUMN"] . " > '" . $arTable["LAST_ID"] . "'" : "") . "\n\t\t\t\t\tORDER BY " . $arTable["KEY_COLUMN"] . "\n\t\t\t\t\tLIMIT 1000\n\t\t\t\t";
            } else {
                $strSelect = "\n\t\t\t\t\tSELECT *\n\t\t\t\t\tFROM " . $arTable["TABLE_NAME"] . "\n\t\t\t\t\tLIMIT " . (strlen($arTable["LAST_ID"]) > 0 ? $arTable["LAST_ID"] . ", " : "") . "1000\n\t\t\t\t";
            }
            $rsSource = $nodeDB1->Query($strSelect, false, '', array("fixed_connection" => true));
            while ($arSource = $rsSource->Fetch()) {
                $i++;
                $di++;
                if (!$strInsert) {
                    $strInsert = "insert into " . $arTable["TABLE_NAME"] . " values";
Exemplo n.º 2
0
 $end_time = time() + 5;
 do {
     $rsTables = $nodeDB->Query("SELECT * FROM b_cluster_table ORDER BY ID", false, '', array("fixed_connection" => true));
     $arTable = $rsTables->Fetch();
     if (!is_array($arTable)) {
         break;
     }
     if (strlen($arTable["LAST_ID"]) <= 0) {
         $strError = CreateNodeTable($DB, $nodeDB, $arTable["TABLE_NAME"]);
     }
     //It is a view
     if ($strError === false) {
         $nodeDB->Query("\n\t\t\t\tDELETE FROM b_cluster_table\n\t\t\t\tWHERE ID = '" . $arTable["ID"] . "'\n\t\t\t", false, '', array("fixed_connection" => true));
         continue;
     }
     $arTable["COLUMNS"] = GetTableColumns($DB, $arTable["TABLE_NAME"]);
     if ($strError) {
         echo $strError;
         break;
     }
     $i = intval($arTable["REC_COUNT"]);
     $di = 0;
     $last_id = '';
     $strInsert = "";
     if (strlen($arTable["KEY_COLUMN"]) > 0) {
         $strSelect = "\n\t\t\t\tSELECT *\n\t\t\t\tFROM " . $arTable["TABLE_NAME"] . "\n\t\t\t\t" . (strlen($arTable["LAST_ID"]) > 0 ? "WHERE " . $arTable["KEY_COLUMN"] . " > '" . $arTable["LAST_ID"] . "'" : "") . "\n\t\t\t\tORDER BY " . $arTable["KEY_COLUMN"] . "\n\t\t\t\tLIMIT 1000\n\t\t\t";
     } else {
         $strSelect = "\n\t\t\t\tSELECT *\n\t\t\t\tFROM " . $arTable["TABLE_NAME"] . "\n\t\t\t\tLIMIT " . (strlen($arTable["LAST_ID"]) > 0 ? $arTable["LAST_ID"] . ", " : "") . "1000\n\t\t\t";
     }
     $rsSource = $DB->Query($strSelect, false, '', array("fixed_connection" => true));
     while ($arSource = $rsSource->Fetch()) {
Exemplo n.º 3
0
function UpdateWorkshopDatabase()
{
    global $dbfields, $pubfiles, $tb;
    // Get current column list if we haven't loaded it yet
    if (!count($dbfields)) {
        // Create table if it's not existing
        $tables = array("{$tb['prefix']}{$tb['pubfiles']}" => array("settings" => array("ENGINE=InnoDB", "DEFAULT CHARSET=latin1", "AUTO_INCREMENT=1"), "fields" => array('db_updated' => 'timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP')));
        CreateTables($tables);
        $dbfields = GetTableColumns("{$tb['prefix']}{$tb['pubfiles']}");
    }
    $result = do_mysql_query("SELECT * FROM `{$tb['prefix']}{$tb['pubfiles']}`");
    while ($row = mysql_fetch_array($result, MYSQL_ASSOC)) {
        $pubfiles[$row['publishedfileid']] = $row;
    }
    $json_pubfiles = GetWorkshopPages();
    file_put_contents("{$cachepath}/workshop.json", $json_pubfiles);
    foreach ($json_pubfiles as $pubfile) {
        foreach ($pubfile as $key => $val) {
            CheckDatabaseField($key, $val);
            if (isset($pubfiles[$pubfile['publishedfileid']])) {
                UpdateDatabaseRow($pubfile['publishedfileid'], $key, $val);
            }
        }
        if (!isset($pubfiles[$pubfile['publishedfileid']])) {
            AddDatabaseRow($pubfile);
        }
    }
}