示例#1
1
文件: DB.php 项目: hhgr/hhgolf
 /**
  * _logQuery
  *
  * @param String $sql     sql-query
  * @param int    $duration
  * @param int    $results result counter
  *
  * @return bool
  */
 private function _logQuery($sql, $duration, $results)
 {
     $logLevelUse = strtolower($this->logger_level);
     if ($logLevelUse != 'trace' && $logLevelUse != 'debug') {
         return false;
     }
     $info = 'time => ' . round($duration, 5) . ' - ' . 'results => ' . $results . ' - ' . 'SQL => ' . UTF8::htmlentities($sql);
     $fileInfo = $this->getFileAndLineFromSql();
     $this->logger(array('debug', '<strong>' . date('d. m. Y G:i:s') . ' (' . $fileInfo['file'] . ' line: ' . $fileInfo['line'] . '):</strong> ' . $info . '<br>', 'sql'));
     return true;
 }
示例#2
0
文件: Stringy.php 项目: voku/stringy
 /**
  * Convert all applicable characters to HTML entities.
  *
  * @param  int|null $flags Optional flags
  *
  * @return Stringy  Object with the resulting $str after being html encoded.
  */
 public function htmlEncode($flags = ENT_COMPAT)
 {
     $str = UTF8::htmlentities($this->str, $flags, $this->encoding);
     return static::create($str, $this->encoding);
 }
示例#3
0
 /**
  * Log the current query via "$this->logger".
  *
  * @param string $sql     sql-query
  * @param int    $duration
  * @param int    $results field_count | insert_id | affected_rows
  * @param bool   $sql_error
  *
  * @return bool
  */
 public function logQuery($sql, $duration, $results, $sql_error = false)
 {
     $logLevelUse = strtolower($this->logger_level);
     if ($sql_error === false && ($logLevelUse !== 'trace' && $logLevelUse !== 'debug')) {
         return false;
     }
     // set log-level
     if ($sql_error === true) {
         $logLevel = 'error';
     } else {
         $logLevel = $logLevelUse;
     }
     // get extra info
     $infoExtra = \mysqli_info($this->_db->getLink());
     if ($infoExtra) {
         $infoExtra = ' | info => ' . $infoExtra;
     }
     //
     // logging
     //
     $info = 'time => ' . round($duration, 5) . ' | results => ' . (int) $results . $infoExtra . ' | SQL => ' . UTF8::htmlentities($sql);
     $fileInfo = $this->getFileAndLineFromSql();
     return $this->logger(array($logLevel, '<strong>' . date('d. m. Y G:i:s') . ' (' . $fileInfo['file'] . ' line: ' . $fileInfo['line'] . '):</strong> ' . $info . '<br>', 'sql'));
 }