Expanded the Profiler and added SQL query profiling.
This commit is contained in:
parent
9bf37c37ec
commit
1a15dfd337
2 changed files with 160 additions and 20 deletions
|
@ -227,16 +227,31 @@ class Database extends Object
|
|||
{
|
||||
try
|
||||
{
|
||||
$start_time = microtime(true);
|
||||
// Establishes if the profiler is enabled
|
||||
$profiler = (isset($this->config->pickles['profiler']) && $this->config->pickles['profiler'] == true && preg_match('/^EXPLAIN /i', $sql) == false);
|
||||
|
||||
// Executes a standard query
|
||||
if ($input_parameters === null)
|
||||
{
|
||||
// Explains the query
|
||||
if ($profiler == true)
|
||||
{
|
||||
$explain = $this->fetchAll('EXPLAIN ' . $sql);
|
||||
}
|
||||
|
||||
$start_time = microtime(true);
|
||||
$this->results = $this->connection->query($sql);
|
||||
}
|
||||
// Executes a prepared statement
|
||||
else
|
||||
{
|
||||
// Explains the query
|
||||
if ($profiler == true)
|
||||
{
|
||||
$explain = $this->fetchAll('EXPLAIN ' . $sql, $input_parameters);
|
||||
}
|
||||
|
||||
$start_time = microtime(true);
|
||||
$this->results = $this->connection->prepare($sql);
|
||||
$this->results->execute($input_parameters);
|
||||
}
|
||||
|
@ -248,6 +263,12 @@ class Database extends Object
|
|||
{
|
||||
Log::slowQuery($duration . ' seconds: ' . $loggable_query);
|
||||
}
|
||||
|
||||
// Logs the information to the profiler
|
||||
if ($profiler == true)
|
||||
{
|
||||
Profiler::logQuery($sql, $input_parameters, isset($explain) ? $explain : false, $duration);
|
||||
}
|
||||
}
|
||||
catch (PDOException $e)
|
||||
{
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue