本文整理汇总了PHP中Illuminate\Database\Connection::getDatabaseName方法的典型用法代码示例。如果您正苦于以下问题:PHP Connection::getDatabaseName方法的具体用法?PHP Connection::getDatabaseName怎么用?PHP Connection::getDatabaseName使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Illuminate\Database\Connection
的用法示例。
在下文中一共展示了Connection::getDatabaseName方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: addQuery
/**
*
* @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);
}
}
示例2: addQuery
/**
*
* @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);
}
}