Skip to content

Commit

Permalink
Bugfix for when sql param is not a questionmark
Browse files Browse the repository at this point in the history
  • Loading branch information
Adam Ludovic committed Jun 5, 2016
1 parent 6f10831 commit 336bd06
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions src/DataCollector/QueryCollector.php
Original file line number Diff line number Diff line change
Expand Up @@ -99,8 +99,9 @@ public function addQuery($query, $bindings, $time, $connection)

$bindings = $this->checkBindings($bindings);
if (!empty($bindings) && $this->renderSqlWithParams) {
foreach ($bindings as $binding) {
$query = preg_replace('/\?/', $pdo->quote($binding), $query, 1);
foreach ($bindings as $key => $binding) {
$regex = is_numeric($key) ? '/\?/' : "/:{$key}/";
$query = preg_replace($regex, $pdo->quote($binding), $query, 1);
}
}

Expand Down Expand Up @@ -196,7 +197,7 @@ protected function performQueryAnalysis($query)
}
return implode("<br />", $hints);
}

/**
* Use a backtrace to search for the origin of the query.
*/
Expand Down Expand Up @@ -291,7 +292,7 @@ protected function normalizeFilename($path)
}
return str_replace(base_path(), '', $path);
}

/**
* Reset the queries.
*/
Expand Down

0 comments on commit 336bd06

Please sign in to comment.