Exemplo n.º 1
0
 function CreateAllIndex($pref)
 {
     $AddIndexArray = GetIndexsArray();
     foreach ($AddIndexArray as $tableName => $indexData) {
         if (is_array($indexData)) {
             foreach ($indexData as $fieldName) {
                 if (!$this->CheckExistIndex($pref, $tableName, $fieldName)) {
                     if (!$this->CreateIndex($pref, $tableName, $fieldName)) {
                         return false;
                     }
                 }
             }
         }
     }
     return true;
 }
Exemplo n.º 2
0
                }
            }
        } else {
            $error = strlen($db->GetError()) > 5 ? '<br />' . $db->GetError() : '';
            echo '<font color="' . COLOR_RED . '"> - can\'t get ' . $prefix . $tableName . ' columns names' . $error . '</font><br />';
            $UpdateIsGood = false;
        }
    } else {
        echo '<font color="' . COLOR_RED . '"> - ' . $prefix . $tableName . ' doesn\'t exist</font><br />';
        $UpdateIsGood = false;
    }
    myFlush();
}
echo '<br /><b>' . ++$p . '</b>. Start creating/updating indexs: <br />';
myFlush();
$AddIndexArray = GetIndexsArray();
$AllTables = $db->AllTableNames();
foreach ($AddIndexArray as $tableName => $indexData) {
    if (is_array($indexData)) {
        foreach ($indexData as $fieldName) {
            if ($db->CheckExistIndex($prefix, $tableName, $fieldName)) {
                echo '<font color="' . COLOR_GREY . '"> - index on ' . $fieldName . ' already exists in ' . $prefix . $tableName . ' table</font><br />';
            } else {
                if (!in_array($prefix . $tableName, $AllTables)) {
                    echo '<font color="' . COLOR_RED . '"> - can\'t create index for ' . $fieldName . ' in ' . $prefix . $tableName . ' table (the table doesn\'t exist)</font><br />';
                } else {
                    if ($db->CreateIndex($prefix, $tableName, $fieldName)) {
                        echo ' - add index on ' . $fieldName . ' in ' . $prefix . $tableName . ' table: <font color="' . COLOR_GREEN . '"><b>done!</b></font><br />';
                    } else {
                        $error = strlen($db->GetError()) > 5 ? '<br />' . $db->GetError() : '';
                        echo '<font color="' . COLOR_RED . '"> - can\'t create index for ' . $fieldName . ' in ' . $prefix . $tableName . ' table' . $error . '</font><br />';