Skip to content

Commit

Permalink
Merge pull request barryvdh#205 from rodrigorigotti/master
Browse files Browse the repository at this point in the history
Minor formatting for debugbar's SQL queries
  • Loading branch information
barryvdh committed Sep 19, 2014
2 parents 5e600f7 + 5b9bf4a commit c537262
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion src/DataCollector/QueryCollector.php
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,7 @@ public function collect()
foreach ($queries as $query) {
$totalTime += $query['time'];
$statements[] = array(
'sql' => $query['query'],
'sql' => $this->formatSql($query['query']),
'params' => (object) $query['bindings'],
'duration' => $query['time'],
'duration_str' => $this->formatDuration($query['time']),
Expand All @@ -209,6 +209,17 @@ public function collect()
return $data;
}

/**
* Removes extra spaces at the beginning and end of the SQL query and its lines.
*
* @param string $sql
* @return string
*/
protected function formatSql($sql)
{
return trim(preg_replace("/\s*\n\s*/", "\n", $sql));
}

/**
* {@inheritDoc}
*/
Expand Down

0 comments on commit c537262

Please sign in to comment.