Commit b0f52806 authored by Benjamin Eberlei's avatar Benjamin Eberlei

Merge pull request #127 from aspendigital/feature-statement-fix

Fix Statement class passing bound objects to SQL logger
parents c89b70f4 527bbfd2
...@@ -42,6 +42,10 @@ class Statement implements \IteratorAggregate, DriverStatement ...@@ -42,6 +42,10 @@ class Statement implements \IteratorAggregate, DriverStatement
* @var array The bound parameters. * @var array The bound parameters.
*/ */
protected $params = array(); protected $params = array();
/**
* @var array The parameter types
*/
protected $types = array();
/** /**
* @var \Doctrine\DBAL\Driver\Statement The underlying driver statement. * @var \Doctrine\DBAL\Driver\Statement The underlying driver statement.
*/ */
...@@ -85,6 +89,7 @@ class Statement implements \IteratorAggregate, DriverStatement ...@@ -85,6 +89,7 @@ class Statement implements \IteratorAggregate, DriverStatement
public function bindValue($name, $value, $type = null) public function bindValue($name, $value, $type = null)
{ {
$this->params[$name] = $value; $this->params[$name] = $value;
$this->types[$name] = $type;
if ($type !== null) { if ($type !== null) {
if (is_string($type)) { if (is_string($type)) {
$type = Type::getType($type); $type = Type::getType($type);
...@@ -126,7 +131,7 @@ class Statement implements \IteratorAggregate, DriverStatement ...@@ -126,7 +131,7 @@ class Statement implements \IteratorAggregate, DriverStatement
{ {
$logger = $this->conn->getConfiguration()->getSQLLogger(); $logger = $this->conn->getConfiguration()->getSQLLogger();
if ($logger) { if ($logger) {
$logger->startQuery($this->sql, $this->params); $logger->startQuery($this->sql, $this->params, $this->types);
} }
$stmt = $this->stmt->execute($params); $stmt = $this->stmt->execute($params);
...@@ -135,6 +140,7 @@ class Statement implements \IteratorAggregate, DriverStatement ...@@ -135,6 +140,7 @@ class Statement implements \IteratorAggregate, DriverStatement
$logger->stopQuery(); $logger->stopQuery();
} }
$this->params = array(); $this->params = array();
$this->types = array();
return $stmt; return $stmt;
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment