Esempio n. 1
0
 public function logQuery(Nette\Database\Connection $connection, $result)
 {
     if ($this->disabled) {
         return;
     }
     $this->count++;
     $source = NULL;
     $trace = $result instanceof \PDOException ? $result->getTrace() : debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS);
     foreach ($trace as $row) {
         if (isset($row['file']) && is_file($row['file']) && !Tracy\Debugger::getBluescreen()->isCollapsed($row['file'])) {
             if (isset($row['function']) && strpos($row['function'], 'call_user_func') === 0 || isset($row['class']) && is_subclass_of($row['class'], '\\Nette\\Database\\Connection')) {
                 continue;
             }
             $source = [$row['file'], (int) $row['line']];
             break;
         }
     }
     if ($result instanceof Nette\Database\ResultSet) {
         $this->totalTime += $result->getTime();
         if ($this->count < $this->maxQueries) {
             $this->queries[] = [$connection, $result->getQueryString(), $result->getParameters(), $source, $result->getTime(), $result->getRowCount(), NULL];
         }
     } elseif ($result instanceof \PDOException && $this->count < $this->maxQueries) {
         $this->queries[] = [$connection, $result->queryString, NULL, $source, NULL, NULL, $result->getMessage()];
     }
 }
 public function logQuery(Connection $connection, $result)
 {
     if (!$result instanceof ResultSet) {
         return;
     }
     $queryString = $result->getQueryString();
     if (Strings::startsWith($queryString, 'EXPLAIN')) {
         return;
     }
     $source = NULL;
     $trace = $result instanceof \PDOException ? $result->getTrace() : debug_backtrace(PHP_VERSION_ID >= 50306 ? DEBUG_BACKTRACE_IGNORE_ARGS : FALSE);
     foreach ($trace as $row) {
         if (isset($row['file']) && is_file($row['file']) && !Debugger::getBluescreen()->isCollapsed($row['file'])) {
             if (isset($row['function']) && strpos($row['function'], 'call_user_func') === 0 || isset($row['class']) && is_subclass_of($row['class'], '\\Nette\\Database\\Connection')) {
                 continue;
             }
             $source = array($row['file'], (int) $row['line']);
             break;
         }
     }
     $sqlQuery = Helpers::dumpSql($queryString, $result->getParameters(), $connection);
     $this->queries[$sqlQuery][] = array($sqlQuery, $source);
 }
Esempio n. 3
0
 /**
  * Use a backtrace to search for the origin of the query.
  */
 public static function findSource()
 {
     $source = null;
     $trace = debug_backtrace(PHP_VERSION_ID >= 50306 ? DEBUG_BACKTRACE_IGNORE_ARGS : false);
     foreach ($trace as $row) {
         if (isset($row['file']) === true && Debugger::getBluescreen()->isCollapsed($row['file']) === false) {
             if (isset($row['function']) && strpos($row['function'], 'call_user_func') === 0 || isset($row['class']) && is_subclass_of($row['class'], '\\Illuminate\\Database\\Connection')) {
                 continue;
             }
             return $source = [$row['file'], (int) $row['line']];
         }
     }
     return $source;
 }