/**
  * sends query to database - this is the private one that must work
  *   - internal functions use this rather than $this->query()
  *
  * Overridden to do logging.
  *
  * @param  string  $string
  * @access private
  * @return mixed none or PEAR_Error
  */
 function _query($string)
 {
     if (common_config('db', 'annotate_queries')) {
         $string = $this->annotateQuery($string);
     }
     $start = microtime(true);
     $result = null;
     if (Event::handle('StartDBQuery', array($this, $string, &$result))) {
         common_perf_counter('query', $string);
         $result = parent::_query($string);
         Event::handle('EndDBQuery', array($this, $string, &$result));
     }
     $delta = microtime(true) - $start;
     $limit = common_config('db', 'log_slow_queries');
     if ($limit > 0 && $delta >= $limit || common_config('db', 'log_queries')) {
         $clean = $this->sanitizeQuery($string);
         common_log(LOG_DEBUG, sprintf("DB query (%0.3fs): %s", $delta, $clean));
     }
     return $result;
 }
 /**
  * sends query to database - this is the private one that must work
  *   - internal functions use this rather than $this->query()
  *
  * Overridden to do logging.
  *
  * @param  string  $string
  * @access private
  * @return mixed none or PEAR_Error
  */
 function _query($string)
 {
     if (common_config('db', 'annotate_queries')) {
         $string = $this->annotateQuery($string);
     }
     $start = microtime(true);
     $fail = false;
     $result = null;
     if (Event::handle('StartDBQuery', array($this, $string, &$result))) {
         common_perf_counter('query', $string);
         try {
             $result = parent::_query($string);
         } catch (Exception $e) {
             $fail = $e;
         }
         Event::handle('EndDBQuery', array($this, $string, &$result));
     }
     $delta = microtime(true) - $start;
     $limit = common_config('db', 'log_slow_queries');
     if ($limit > 0 && $delta >= $limit || common_config('db', 'log_queries')) {
         $clean = $this->sanitizeQuery($string);
         if ($fail) {
             $msg = sprintf("FAILED DB query (%0.3fs): %s - %s", $delta, $fail->getMessage(), $clean);
         } else {
             $msg = sprintf("DB query (%0.3fs): %s", $delta, $clean);
         }
         common_log(LOG_DEBUG, $msg);
     }
     if ($fail) {
         throw $fail;
     }
     return $result;
 }
Example #3
0
 /**
  * Delete the value associated with a key
  *
  * @param string $key Key to delete
  *
  * @return boolean success flag
  */
 function delete($key)
 {
     $success = false;
     common_perf_counter('Cache::delete', $key);
     if (Event::handle('StartCacheDelete', array(&$key, &$success))) {
         if (array_key_exists($key, $this->_items)) {
             unset($this->_items[$key]);
         }
         $success = true;
         Event::handle('EndCacheDelete', array($key));
     }
     return $success;
 }