Exemplo n.º 1
0
 protected static function finishQueryLog(&$queryLog, $result = false)
 {
     if ($queryLog == false) {
         return false;
     }
     // save finish time and number of affected rows
     $queryLog['time_finish'] = sprintf('%f', microtime(true));
     $queryLog['time_duration_ms'] = ($queryLog['time_finish'] - $queryLog['time_start']) * 1000;
     $queryLog['affected_rows'] = self::getMysqli()->affected_rows;
     // save result information
     if ($result) {
         $queryLog['result_fields'] = $result->field_count;
         $queryLog['result_rows'] = $result->num_rows;
     }
     // build backtrace string
     $queryLog['method'] = '';
     $backtrace = debug_backtrace();
     while ($backtick = array_shift($backtrace)) {
         // skip the log routine itself
         if ($backtick['function'] == __FUNCTION__) {
             continue;
         }
         if ($backtick['class'] != __CLASS__) {
             break;
         }
         // append function
         if ($queryLog['method'] != '') {
             $queryLog['method'] .= '/';
         }
         $queryLog['method'] .= $backtick['function'];
     }
     // append to static log
     if (MICS::isFeatureLoaded('DebugLog')) {
         DebugLog::log($queryLog);
     }
 }