Commit 7da630a1 authored by Benjamin Eberlei's avatar Benjamin Eberlei

Change Doctrine DBAL statement variables to protected, closes #GH-70

parent 7101ecd7
...@@ -37,23 +37,23 @@ class Statement implements \IteratorAggregate, DriverStatement ...@@ -37,23 +37,23 @@ class Statement implements \IteratorAggregate, DriverStatement
/** /**
* @var string The SQL statement. * @var string The SQL statement.
*/ */
private $_sql; protected $sql;
/** /**
* @var array The bound parameters. * @var array The bound parameters.
*/ */
private $_params = array(); protected $params = array();
/** /**
* @var Doctrine\DBAL\Driver\Statement The underlying driver statement. * @var Doctrine\DBAL\Driver\Statement The underlying driver statement.
*/ */
private $_stmt; protected $stmt;
/** /**
* @var Doctrine\DBAL\Platforms\AbstractPlatform The underlying database platform. * @var Doctrine\DBAL\Platforms\AbstractPlatform The underlying database platform.
*/ */
private $_platform; protected $platform;
/** /**
* @var Doctrine\DBAL\Connection The connection this statement is bound to and executed on. * @var Doctrine\DBAL\Connection The connection this statement is bound to and executed on.
*/ */
private $_conn; protected $conn;
/** /**
* Creates a new <tt>Statement</tt> for the given SQL and <tt>Connection</tt>. * Creates a new <tt>Statement</tt> for the given SQL and <tt>Connection</tt>.
...@@ -63,10 +63,10 @@ class Statement implements \IteratorAggregate, DriverStatement ...@@ -63,10 +63,10 @@ class Statement implements \IteratorAggregate, DriverStatement
*/ */
public function __construct($sql, Connection $conn) public function __construct($sql, Connection $conn)
{ {
$this->_sql = $sql; $this->sql = $sql;
$this->_stmt = $conn->getWrappedConnection()->prepare($sql); $this->stmt = $conn->getWrappedConnection()->prepare($sql);
$this->_conn = $conn; $this->conn = $conn;
$this->_platform = $conn->getDatabasePlatform(); $this->platform = $conn->getDatabasePlatform();
} }
/** /**
...@@ -84,20 +84,20 @@ class Statement implements \IteratorAggregate, DriverStatement ...@@ -84,20 +84,20 @@ 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;
if ($type !== null) { if ($type !== null) {
if (is_string($type)) { if (is_string($type)) {
$type = Type::getType($type); $type = Type::getType($type);
} }
if ($type instanceof Type) { if ($type instanceof Type) {
$value = $type->convertToDatabaseValue($value, $this->_platform); $value = $type->convertToDatabaseValue($value, $this->platform);
$bindingType = $type->getBindingType(); $bindingType = $type->getBindingType();
} else { } else {
$bindingType = $type; // PDO::PARAM_* constants $bindingType = $type; // PDO::PARAM_* constants
} }
return $this->_stmt->bindValue($name, $value, $bindingType); return $this->stmt->bindValue($name, $value, $bindingType);
} else { } else {
return $this->_stmt->bindValue($name, $value); return $this->stmt->bindValue($name, $value);
} }
} }
...@@ -113,7 +113,7 @@ class Statement implements \IteratorAggregate, DriverStatement ...@@ -113,7 +113,7 @@ class Statement implements \IteratorAggregate, DriverStatement
*/ */
public function bindParam($name, &$var, $type = PDO::PARAM_STR) public function bindParam($name, &$var, $type = PDO::PARAM_STR)
{ {
return $this->_stmt->bindParam($name, $var, $type); return $this->stmt->bindParam($name, $var, $type);
} }
/** /**
...@@ -123,17 +123,17 @@ class Statement implements \IteratorAggregate, DriverStatement ...@@ -123,17 +123,17 @@ class Statement implements \IteratorAggregate, DriverStatement
*/ */
public function execute($params = null) public function execute($params = null)
{ {
$hasLogger = $this->_conn->getConfiguration()->getSQLLogger(); $hasLogger = $this->conn->getConfiguration()->getSQLLogger();
if ($hasLogger) { if ($hasLogger) {
$this->_conn->getConfiguration()->getSQLLogger()->startQuery($this->_sql, $this->_params); $this->conn->getConfiguration()->getSQLLogger()->startQuery($this->sql, $this->params);
} }
$stmt = $this->_stmt->execute($params); $stmt = $this->stmt->execute($params);
if ($hasLogger) { if ($hasLogger) {
$this->_conn->getConfiguration()->getSQLLogger()->stopQuery(); $this->conn->getConfiguration()->getSQLLogger()->stopQuery();
} }
$this->_params = array(); $this->params = array();
return $stmt; return $stmt;
} }
...@@ -144,7 +144,7 @@ class Statement implements \IteratorAggregate, DriverStatement ...@@ -144,7 +144,7 @@ class Statement implements \IteratorAggregate, DriverStatement
*/ */
public function closeCursor() public function closeCursor()
{ {
return $this->_stmt->closeCursor(); return $this->stmt->closeCursor();
} }
/** /**
...@@ -154,7 +154,7 @@ class Statement implements \IteratorAggregate, DriverStatement ...@@ -154,7 +154,7 @@ class Statement implements \IteratorAggregate, DriverStatement
*/ */
public function columnCount() public function columnCount()
{ {
return $this->_stmt->columnCount(); return $this->stmt->columnCount();
} }
/** /**
...@@ -164,7 +164,7 @@ class Statement implements \IteratorAggregate, DriverStatement ...@@ -164,7 +164,7 @@ class Statement implements \IteratorAggregate, DriverStatement
*/ */
public function errorCode() public function errorCode()
{ {
return $this->_stmt->errorCode(); return $this->stmt->errorCode();
} }
/** /**
...@@ -174,17 +174,17 @@ class Statement implements \IteratorAggregate, DriverStatement ...@@ -174,17 +174,17 @@ class Statement implements \IteratorAggregate, DriverStatement
*/ */
public function errorInfo() public function errorInfo()
{ {
return $this->_stmt->errorInfo(); return $this->stmt->errorInfo();
} }
public function setFetchMode($fetchStyle) public function setFetchMode($fetchStyle)
{ {
return $this->_stmt->setFetchMode($fetchStyle); return $this->stmt->setFetchMode($fetchStyle);
} }
public function getIterator() public function getIterator()
{ {
return $this->_stmt; return $this->stmt;
} }
/** /**
...@@ -196,7 +196,7 @@ class Statement implements \IteratorAggregate, DriverStatement ...@@ -196,7 +196,7 @@ class Statement implements \IteratorAggregate, DriverStatement
*/ */
public function fetch($fetchStyle = PDO::FETCH_BOTH) public function fetch($fetchStyle = PDO::FETCH_BOTH)
{ {
return $this->_stmt->fetch($fetchStyle); return $this->stmt->fetch($fetchStyle);
} }
/** /**
...@@ -209,9 +209,9 @@ class Statement implements \IteratorAggregate, DriverStatement ...@@ -209,9 +209,9 @@ class Statement implements \IteratorAggregate, DriverStatement
public function fetchAll($fetchStyle = PDO::FETCH_BOTH, $columnIndex = 0) public function fetchAll($fetchStyle = PDO::FETCH_BOTH, $columnIndex = 0)
{ {
if ($columnIndex != 0) { if ($columnIndex != 0) {
return $this->_stmt->fetchAll($fetchStyle, $columnIndex); return $this->stmt->fetchAll($fetchStyle, $columnIndex);
} }
return $this->_stmt->fetchAll($fetchStyle); return $this->stmt->fetchAll($fetchStyle);
} }
/** /**
...@@ -222,7 +222,7 @@ class Statement implements \IteratorAggregate, DriverStatement ...@@ -222,7 +222,7 @@ class Statement implements \IteratorAggregate, DriverStatement
*/ */
public function fetchColumn($columnIndex = 0) public function fetchColumn($columnIndex = 0)
{ {
return $this->_stmt->fetchColumn($columnIndex); return $this->stmt->fetchColumn($columnIndex);
} }
/** /**
...@@ -232,7 +232,7 @@ class Statement implements \IteratorAggregate, DriverStatement ...@@ -232,7 +232,7 @@ class Statement implements \IteratorAggregate, DriverStatement
*/ */
public function rowCount() public function rowCount()
{ {
return $this->_stmt->rowCount(); return $this->stmt->rowCount();
} }
/** /**
...@@ -242,6 +242,6 @@ class Statement implements \IteratorAggregate, DriverStatement ...@@ -242,6 +242,6 @@ class Statement implements \IteratorAggregate, DriverStatement
*/ */
public function getWrappedStatement() public function getWrappedStatement()
{ {
return $this->_stmt; return $this->stmt;
} }
} }
\ No newline at end of file
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