diff --git a/chromedriver b/chromedriver
new file mode 100755
index 0000000..5a809fa
Binary files /dev/null and b/chromedriver differ
diff --git a/demo/bridge/doctrine/index.php b/demo/bridge/doctrine/index.php
index 183d9ae..9a00acf 100644
--- a/demo/bridge/doctrine/index.php
+++ b/demo/bridge/doctrine/index.php
@@ -12,7 +12,8 @@ $debugbar->addCollector(new DebugBar\Bridge\DoctrineCollector($debugStack));
$product = new Demo\Product();
$product->setName("foobar");
+
$entityManager->persist($product);
$entityManager->flush();
-
+$entityManager->createQuery("select p from Demo\\Product p where p.name=:c")->setParameter("c", "")->execute();
render_demo_page();
diff --git a/demo/pdo.php b/demo/pdo.php
index 8a91272..2dab3c8 100644
--- a/demo/pdo.php
+++ b/demo/pdo.php
@@ -19,6 +19,10 @@ $stmt = $pdo->prepare('select * from users where name=?');
$stmt->execute(array('foo'));
$foo = $stmt->fetch();
+$stmt = $pdo->prepare('select * from users where name=?');
+$stmt->execute(array(''));
+$foo = $stmt->fetch();
+
$pdo->exec('delete from users');
render_demo_page();
diff --git a/src/DebugBar/Bridge/DoctrineCollector.php b/src/DebugBar/Bridge/DoctrineCollector.php
index 7c91da9..3a3f60b 100644
--- a/src/DebugBar/Bridge/DoctrineCollector.php
+++ b/src/DebugBar/Bridge/DoctrineCollector.php
@@ -60,7 +60,7 @@ class DoctrineCollector extends DataCollector implements Renderable, AssetProvid
foreach ($this->debugStack->queries as $q) {
$queries[] = array(
'sql' => $q['sql'],
- 'params' => (object) $q['params'],
+ 'params' => (object) $this->getParameters($q),
'duration' => $q['executionMS'],
'duration_str' => $this->formatDuration($q['executionMS'])
);
@@ -75,6 +75,20 @@ class DoctrineCollector extends DataCollector implements Renderable, AssetProvid
);
}
+ /**
+ * Returns an array of parameters used with the query
+ *
+ * @return array
+ */
+ public function getParameters($query) : array
+ {
+ $params = [];
+ foreach ($query['params'] as $name => $param) {
+ $params[$name] = htmlentities($param?:"", ENT_QUOTES, 'UTF-8', false);
+ }
+ return $params;
+ }
+
/**
* @return string
*/
diff --git a/tests/DebugBar/Tests/Browser/Bridge/DoctrineTest.php b/tests/DebugBar/Tests/Browser/Bridge/DoctrineTest.php
index 2d9e320..d66caa2 100644
--- a/tests/DebugBar/Tests/Browser/Bridge/DoctrineTest.php
+++ b/tests/DebugBar/Tests/Browser/Bridge/DoctrineTest.php
@@ -33,7 +33,7 @@ class DoctrineTest extends AbstractBrowserTest
});
$this->assertEquals('INSERT INTO products (name) VALUES (?)', $statements[1]);
- $this->assertCount(3, $statements);
+ $this->assertCount(4, $statements);
}
}
\ No newline at end of file
diff --git a/tests/DebugBar/Tests/Browser/PdoTest.php b/tests/DebugBar/Tests/Browser/PdoTest.php
new file mode 100644
index 0000000..2f256ce
--- /dev/null
+++ b/tests/DebugBar/Tests/Browser/PdoTest.php
@@ -0,0 +1,34 @@
+request('GET', '/demo/pdo.php');
+
+ // Wait for Debugbar to load
+ $crawler = $client->waitFor('.phpdebugbar-body');
+ usleep(1000);
+
+ if (!$this->isTabActive($crawler, 'database')) {
+ $client->click($this->getTabLink($crawler, 'database'));
+ }
+
+ $crawler = $client->waitForVisibility('.phpdebugbar-panel[data-collector=database]');
+
+ $statements = $crawler->filter('.phpdebugbar-panel[data-collector=database] .phpdebugbar-widgets-sql')
+ ->each(function($node){
+ return $node->getText();
+ });
+
+ $this->assertEquals('insert into users (name) values (?)', $statements[1]);
+ $this->assertCount(7, $statements);
+ }
+
+}
\ No newline at end of file