Exemplo n.º 1
0
 /**
  * Optimize a table and write returned message to log file.
  *
  * Returns true on success or MySQL-Error.
  *
  * @param MsdDbFactory $dbo   Database object
  * @param string       $table Name of table
  *
  * @return bool
  */
 public static function optimizeTable(MsdDbFactory $dbo, $table)
 {
     global $lang, $log;
     $res = $dbo->optimizeTable($table);
     if (false !== $res) {
         $success = array('status', 'info', 'warning', 'note');
         if (in_array($res['Msg_type'], $success)) {
             $logMsg = $lang['L_OPTIMIZE'] . ' `' . $dbo->dbSelected . '`.`';
             $logMsg .= $table . '`: ' . $res['Msg_text'];
             $log->write(Log::PHP, $logMsg);
             return true;
         } else {
             $logMsg = sprintf($lang['L_OPTIMIZE_TABLE_ERR'], $table);
             writeToErrorLog($dbo->dbSelected, $logMsg, $res['msg_text'], 0);
             return false;
         }
     } else {
         $logMsg = sprintf($lang['L_OPTIMIZE_TABLE_ERR'], $table);
         writeToErrorLog($dbo->dbSelecte, $logMsg, $res['msg_text'], 0);
         return false;
     }
 }