Esempio n. 1
0
 public function applySQLUpdateFile($sqlFile = 'db-update.sql')
 {
     $this->printStartNextStepMsg('Read SQL update file');
     $success = true;
     $message = null;
     if (!file_exists($sqlFile)) {
         $message = 'file <i>' . $sqlFile . '</i> does not exist, nothing to do !';
     } else {
         // read sql update file and set the table prefix
         $sql = str_replace(TBL_NAME_PREFIX, $this->config->getTablePrefix(), @file_get_contents($sqlFile));
         $this->printEndStepMsg(true);
         $this->printStartNextStepMsg('Run SQL queries');
         $res = DBHelper::exec($sql, true);
         if ($res != null) {
             $success = false;
             $message = $res;
             $this->error++;
         }
         DBHelper::clearStoredResults();
     }
     $this->printEndStepMsg($success, $message);
     return $success;
 }
Esempio n. 2
0
            echo '<i style="padding-left:30px;" >|_ Update reports in (' . implode(', ', $issue['reports']) . ') with issue id ' . $issueId . ' ... </i>';
            if (DBHelper::updateReportsIssue($issue['reports'], $issueId)) {
                echo '<i>OK</i><br/>';
            } else {
                echo '<i style="color:red" >FAILED</i><br/>';
            }
        } else {
            echo '<i style="color:red" >FAILED</i><br/>';
            echo '<i style="padding-left:30px; color:red; font-weight:bold;" >' . DBHelper::getLastError() . '</i><br/>';
        }
    }
} catch (Exception $e) {
    echo '<b style="padding-left:30px; color:red;" >' . $e->getMessage() . '</b><br/>';
    exit;
}
echo '<b>Step 5.</b> ... OK<br/>';
echo '<b>Step 6.</b> Create database triggers ... ';
$res = DBHelper::exec($sql[1], true);
if ($res != null) {
    echo '<br/><b style="padding-left:30px; color:red;" >' . $res . '</b>';
    exit;
}
DBHelper::clearStoredResults();
// count triggers
$res = DBHelper::countRows('information_schema.triggers', null, true);
if ($res != 4) {
    echo '<b style="color:red" >FAILED</b><br/><b style="padding-left:30px; color:red;" >All triggers not created properly !</b>';
} else {
    echo 'OK<br/>';
}
echo '<p><b style="color:green" >UPDATE IS COMPLETE !</b></p>';