From 336bd06a329799720c7b7608c474a2d4b763294e Mon Sep 17 00:00:00 2001 From: Adam Ludovic Date: Sun, 5 Jun 2016 04:40:30 +0300 Subject: [PATCH] Bugfix for when sql param is not a questionmark --- src/DataCollector/QueryCollector.php | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/DataCollector/QueryCollector.php b/src/DataCollector/QueryCollector.php index e25c7438..7234caec 100644 --- a/src/DataCollector/QueryCollector.php +++ b/src/DataCollector/QueryCollector.php @@ -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); } } @@ -196,7 +197,7 @@ protected function performQueryAnalysis($query) } return implode("
", $hints); } - + /** * Use a backtrace to search for the origin of the query. */ @@ -291,7 +292,7 @@ protected function normalizeFilename($path) } return str_replace(base_path(), '', $path); } - + /** * Reset the queries. */