Commit 56f1f898 authored by Benjamin Eberlei's avatar Benjamin Eberlei

Merge pull request #117 from nicolas-grekas/logger

missing call to logger in Connection->exec(), cleanups
parents b89d65c3 2a1e0701
...@@ -614,9 +614,9 @@ class Connection implements DriverConnection ...@@ -614,9 +614,9 @@ class Connection implements DriverConnection
$this->connect(); $this->connect();
$hasLogger = $this->_config->getSQLLogger() !== null; $logger = $this->_config->getSQLLogger();
if ($hasLogger) { if ($logger) {
$this->_config->getSQLLogger()->startQuery($query, $params, $types); $logger->startQuery($query, $params, $types);
} }
if ($params) { if ($params) {
...@@ -633,8 +633,8 @@ class Connection implements DriverConnection ...@@ -633,8 +633,8 @@ class Connection implements DriverConnection
$stmt = $this->_conn->query($query); $stmt = $this->_conn->query($query);
} }
if ($hasLogger) { if ($logger) {
$this->_config->getSQLLogger()->stopQuery(); $logger->stopQuery();
} }
return $stmt; return $stmt;
...@@ -708,7 +708,7 @@ class Connection implements DriverConnection ...@@ -708,7 +708,7 @@ class Connection implements DriverConnection
$args = func_get_args(); $args = func_get_args();
$logger = $this->getConfiguration()->getSQLLogger(); $logger = $this->_config->getSQLLogger();
if ($logger) { if ($logger) {
$logger->startQuery($args[0]); $logger->startQuery($args[0]);
} }
...@@ -738,9 +738,9 @@ class Connection implements DriverConnection ...@@ -738,9 +738,9 @@ class Connection implements DriverConnection
{ {
$this->connect(); $this->connect();
$hasLogger = $this->_config->getSQLLogger() !== null; $logger = $this->_config->getSQLLogger();
if ($hasLogger) { if ($logger) {
$this->_config->getSQLLogger()->startQuery($query, $params, $types); $logger->startQuery($query, $params, $types);
} }
if ($params) { if ($params) {
...@@ -758,8 +758,8 @@ class Connection implements DriverConnection ...@@ -758,8 +758,8 @@ class Connection implements DriverConnection
$result = $this->_conn->exec($query); $result = $this->_conn->exec($query);
} }
if ($hasLogger) { if ($logger) {
$this->_config->getSQLLogger()->stopQuery(); $logger->stopQuery();
} }
return $result; return $result;
...@@ -774,7 +774,19 @@ class Connection implements DriverConnection ...@@ -774,7 +774,19 @@ class Connection implements DriverConnection
public function exec($statement) public function exec($statement)
{ {
$this->connect(); $this->connect();
return $this->_conn->exec($statement);
$logger = $this->_config->getSQLLogger();
if ($logger) {
$logger->startQuery($statement);
}
$result = $this->_conn->exec($statement);
if ($logger) {
$logger->stopQuery();
}
return $result;
} }
/** /**
......
...@@ -123,15 +123,15 @@ class Statement implements \IteratorAggregate, DriverStatement ...@@ -123,15 +123,15 @@ class Statement implements \IteratorAggregate, DriverStatement
*/ */
public function execute($params = null) public function execute($params = null)
{ {
$hasLogger = $this->conn->getConfiguration()->getSQLLogger(); $logger = $this->conn->getConfiguration()->getSQLLogger();
if ($hasLogger) { if ($logger) {
$this->conn->getConfiguration()->getSQLLogger()->startQuery($this->sql, $this->params); $logger->startQuery($this->sql, $this->params);
} }
$stmt = $this->stmt->execute($params); $stmt = $this->stmt->execute($params);
if ($hasLogger) { if ($logger) {
$this->conn->getConfiguration()->getSQLLogger()->stopQuery(); $logger->stopQuery();
} }
$this->params = array(); $this->params = 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