Get the name of the connected database.
public getDatabaseName ( ) : string | ||
리턴 | string |
/** * * @param string $query * @param array $bindings * @param float $time * @param \Illuminate\Database\Connection $connection */ public function addQuery($query, $bindings, $time, $connection) { $explainResults = array(); $time = $time / 1000; $endTime = microtime(true); $startTime = $endTime - $time; $hints = $this->performQueryAnalysis($query); $pdo = $connection->getPdo(); $bindings = $connection->prepareBindings($bindings); // Run EXPLAIN on this query (if needed) if ($this->explainQuery && preg_match('/^(' . implode($this->explainTypes) . ') /i', $query)) { $statement = $pdo->prepare('EXPLAIN ' . $query); $statement->execute($bindings); $explainResults = $statement->fetchAll(\PDO::FETCH_CLASS); } $bindings = $this->checkBindings($bindings); if (!empty($bindings) && $this->renderSqlWithParams) { foreach ($bindings as $binding) { $query = preg_replace('/\\?/', $pdo->quote($binding), $query, 1); } } $source = null; if ($this->findSource) { try { $source = $this->findSource(); } catch (\Exception $e) { } } $this->queries[] = array('query' => $query, 'bindings' => $this->escapeBindings($bindings), 'time' => $time, 'source' => $source, 'explain' => $explainResults, 'connection' => $connection->getDatabaseName(), 'hints' => $this->showHints ? $hints : null); if ($this->timeCollector !== null) { $this->timeCollector->addMeasure($query, $startTime, $endTime); } }
/** * * @param string $query * @param array $bindings * @param float $time * @param \Illuminate\Database\Connection $connection */ public function addQuery($query, $bindings, $time, $connection) { $explainResults = []; $time = $time / 1000; $endTime = microtime(true); $startTime = $endTime - $time; $hints = $this->performQueryAnalysis($query); $pdo = $connection->getPdo(); $bindings = $connection->prepareBindings($bindings); // Run EXPLAIN on this query (if needed) if ($this->explainQuery && preg_match('/^(' . implode($this->explainTypes) . ') /i', $query)) { $statement = $pdo->prepare('EXPLAIN ' . $query); $statement->execute($bindings); $explainResults = $statement->fetchAll(\PDO::FETCH_CLASS); } $bindings = $this->checkBindings($bindings); if (!empty($bindings) && $this->renderSqlWithParams) { foreach ($bindings as $key => $binding) { // This regex matches placeholders only, not the question marks, // nested in quotes, while we iterate through the bindings // and substitute placeholders by suitable values. $regex = is_numeric($key) ? "/\\?(?=(?:[^'\\\\']*'[^'\\\\']*')*[^'\\\\']*\$)/" : "/:{$key}(?=(?:[^'\\\\']*'[^'\\\\']*')*[^'\\\\']*\$)/"; $query = preg_replace($regex, $pdo->quote($binding), $query, 1); } } $source = null; if ($this->findSource) { try { $source = $this->findSource(); } catch (\Exception $e) { } } $this->queries[] = ['query' => $query, 'bindings' => $this->escapeBindings($bindings), 'time' => $time, 'source' => $source, 'explain' => $explainResults, 'connection' => $connection->getDatabaseName(), 'hints' => $this->showHints ? $hints : null]; if ($this->timeCollector !== null) { $this->timeCollector->addMeasure($query, $startTime, $endTime); } }