Commit c0533c1d authored by Nicolas Grekas's avatar Nicolas Grekas

use "fetchMode" instead of "fetchStyle"

parent e0d1cd21
...@@ -27,7 +27,7 @@ class ArrayStatement implements \IteratorAggregate, ResultStatement ...@@ -27,7 +27,7 @@ class ArrayStatement implements \IteratorAggregate, ResultStatement
private $data; private $data;
private $columnCount = 0; private $columnCount = 0;
private $num = 0; private $num = 0;
private $defaultFetchStyle = PDO::FETCH_BOTH; private $defaultFetchMode = PDO::FETCH_BOTH;
public function __construct(array $data) public function __construct(array $data)
{ {
...@@ -47,13 +47,13 @@ class ArrayStatement implements \IteratorAggregate, ResultStatement ...@@ -47,13 +47,13 @@ class ArrayStatement implements \IteratorAggregate, ResultStatement
return $this->columnCount; return $this->columnCount;
} }
public function setFetchMode($fetchStyle, $arg2 = null, $arg3 = null) public function setFetchMode($fetchMode, $arg2 = null, $arg3 = null)
{ {
if ($arg2 !== null || $arg3 !== null) { if ($arg2 !== null || $arg3 !== null) {
throw new \InvalidArgumentException("Caching layer does not support 2nd/3rd argument to setFetchMode()"); throw new \InvalidArgumentException("Caching layer does not support 2nd/3rd argument to setFetchMode()");
} }
$this->defaultFetchStyle = $fetchStyle; $this->defaultFetchMode = $fetchMode;
} }
public function getIterator() public function getIterator()
...@@ -62,18 +62,18 @@ class ArrayStatement implements \IteratorAggregate, ResultStatement ...@@ -62,18 +62,18 @@ class ArrayStatement implements \IteratorAggregate, ResultStatement
return new \ArrayIterator($data); return new \ArrayIterator($data);
} }
public function fetch($fetchStyle = null) public function fetch($fetchMode = null)
{ {
if (isset($this->data[$this->num])) { if (isset($this->data[$this->num])) {
$row = $this->data[$this->num++]; $row = $this->data[$this->num++];
$fetchStyle = $fetchStyle ?: $this->defaultFetchStyle; $fetchMode = $fetchMode ?: $this->defaultFetchMode;
if ($fetchStyle === PDO::FETCH_ASSOC) { if ($fetchMode === PDO::FETCH_ASSOC) {
return $row; return $row;
} else if ($fetchStyle === PDO::FETCH_NUM) { } else if ($fetchMode === PDO::FETCH_NUM) {
return array_values($row); return array_values($row);
} else if ($fetchStyle === PDO::FETCH_BOTH) { } else if ($fetchMode === PDO::FETCH_BOTH) {
return array_merge($row, array_values($row)); return array_merge($row, array_values($row));
} else if ($fetchStyle === PDO::FETCH_COLUMN) { } else if ($fetchMode === PDO::FETCH_COLUMN) {
return reset($row); return reset($row);
} else { } else {
throw new \InvalidArgumentException("Invalid fetch-style given for fetching result."); throw new \InvalidArgumentException("Invalid fetch-style given for fetching result.");
...@@ -82,10 +82,10 @@ class ArrayStatement implements \IteratorAggregate, ResultStatement ...@@ -82,10 +82,10 @@ class ArrayStatement implements \IteratorAggregate, ResultStatement
return false; return false;
} }
public function fetchAll($fetchStyle = null) public function fetchAll($fetchMode = null)
{ {
$rows = array(); $rows = array();
while ($row = $this->fetch($fetchStyle)) { while ($row = $this->fetch($fetchMode)) {
$rows[] = $row; $rows[] = $row;
} }
return $rows; return $rows;
......
...@@ -81,7 +81,7 @@ class ResultCacheStatement implements \IteratorAggregate, ResultStatement ...@@ -81,7 +81,7 @@ class ResultCacheStatement implements \IteratorAggregate, ResultStatement
/** /**
* @var int * @var int
*/ */
private $defaultFetchStyle = PDO::FETCH_BOTH; private $defaultFetchMode = PDO::FETCH_BOTH;
/** /**
* @param Statement $stmt * @param Statement $stmt
...@@ -132,9 +132,9 @@ class ResultCacheStatement implements \IteratorAggregate, ResultStatement ...@@ -132,9 +132,9 @@ class ResultCacheStatement implements \IteratorAggregate, ResultStatement
return $this->statement->columnCount(); return $this->statement->columnCount();
} }
public function setFetchMode($fetchStyle, $arg2 = null, $arg3 = null) public function setFetchMode($fetchMode, $arg2 = null, $arg3 = null)
{ {
$this->defaultFetchStyle = $fetchStyle; $this->defaultFetchMode = $fetchMode;
} }
public function getIterator() public function getIterator()
...@@ -147,13 +147,13 @@ class ResultCacheStatement implements \IteratorAggregate, ResultStatement ...@@ -147,13 +147,13 @@ class ResultCacheStatement implements \IteratorAggregate, ResultStatement
* fetch * fetch
* *
* @see Query::HYDRATE_* constants * @see Query::HYDRATE_* constants
* @param integer $fetchStyle Controls how the next row will be returned to the caller. * @param integer $fetchMode Controls how the next row will be returned to the caller.
* This value must be one of the Query::HYDRATE_* constants, * This value must be one of the Query::HYDRATE_* constants,
* defaulting to Query::HYDRATE_BOTH * defaulting to Query::HYDRATE_BOTH
* *
* @return mixed * @return mixed
*/ */
public function fetch($fetchStyle = null) public function fetch($fetchMode = null)
{ {
if ($this->data === null) { if ($this->data === null) {
$this->data = array(); $this->data = array();
...@@ -163,15 +163,15 @@ class ResultCacheStatement implements \IteratorAggregate, ResultStatement ...@@ -163,15 +163,15 @@ class ResultCacheStatement implements \IteratorAggregate, ResultStatement
if ($row) { if ($row) {
$this->data[] = $row; $this->data[] = $row;
$fetchStyle = $fetchStyle ?: $this->defaultFetchStyle; $fetchMode = $fetchMode ?: $this->defaultFetchMode;
if ($fetchStyle == PDO::FETCH_ASSOC) { if ($fetchMode == PDO::FETCH_ASSOC) {
return $row; return $row;
} else if ($fetchStyle == PDO::FETCH_NUM) { } else if ($fetchMode == PDO::FETCH_NUM) {
return array_values($row); return array_values($row);
} else if ($fetchStyle == PDO::FETCH_BOTH) { } else if ($fetchMode == PDO::FETCH_BOTH) {
return array_merge($row, array_values($row)); return array_merge($row, array_values($row));
} else if ($fetchStyle == PDO::FETCH_COLUMN) { } else if ($fetchMode == PDO::FETCH_COLUMN) {
return reset($row); return reset($row);
} else { } else {
throw new \InvalidArgumentException("Invalid fetch-style given for caching result."); throw new \InvalidArgumentException("Invalid fetch-style given for caching result.");
...@@ -184,16 +184,16 @@ class ResultCacheStatement implements \IteratorAggregate, ResultStatement ...@@ -184,16 +184,16 @@ class ResultCacheStatement implements \IteratorAggregate, ResultStatement
/** /**
* Returns an array containing all of the result set rows * Returns an array containing all of the result set rows
* *
* @param integer $fetchStyle Controls how the next row will be returned to the caller. * @param integer $fetchMode Controls how the next row will be returned to the caller.
* This value must be one of the Query::HYDRATE_* constants, * This value must be one of the Query::HYDRATE_* constants,
* defaulting to Query::HYDRATE_BOTH * defaulting to Query::HYDRATE_BOTH
* *
* @return array * @return array
*/ */
public function fetchAll($fetchStyle = null) public function fetchAll($fetchMode = null)
{ {
$rows = array(); $rows = array();
while ($row = $this->fetch($fetchStyle)) { while ($row = $this->fetch($fetchMode)) {
$rows[] = $row; $rows[] = $row;
} }
return $rows; return $rows;
......
...@@ -173,7 +173,7 @@ class Connection implements DriverConnection ...@@ -173,7 +173,7 @@ class Connection implements DriverConnection
*/ */
private $_isRollbackOnly = false; private $_isRollbackOnly = false;
private $_defaultFetchStyle = PDO::FETCH_ASSOC; private $_defaultFetchMode = PDO::FETCH_ASSOC;
/** /**
* Initializes a new instance of the Connection class. * Initializes a new instance of the Connection class.
...@@ -361,11 +361,11 @@ class Connection implements DriverConnection ...@@ -361,11 +361,11 @@ class Connection implements DriverConnection
/** /**
* setFetchMode * setFetchMode
* *
* @param integer $fetchStyle * @param integer $fetchMode
*/ */
public function setFetchMode($fetchStyle) public function setFetchMode($fetchMode)
{ {
$this->_defaultFetchStyle = $fetchStyle; $this->_defaultFetchMode = $fetchMode;
} }
/** /**
...@@ -605,7 +605,7 @@ class Connection implements DriverConnection ...@@ -605,7 +605,7 @@ class Connection implements DriverConnection
$this->connect(); $this->connect();
$stmt = new Statement($statement, $this); $stmt = new Statement($statement, $this);
$stmt->setFetchMode($this->_defaultFetchStyle); $stmt->setFetchMode($this->_defaultFetchMode);
return $stmt; return $stmt;
} }
...@@ -650,7 +650,7 @@ class Connection implements DriverConnection ...@@ -650,7 +650,7 @@ class Connection implements DriverConnection
$stmt = $this->_conn->query($query); $stmt = $this->_conn->query($query);
} }
$stmt->setFetchMode($this->_defaultFetchStyle); $stmt->setFetchMode($this->_defaultFetchMode);
if ($logger) { if ($logger) {
$logger->stopQuery(); $logger->stopQuery();
...@@ -691,7 +691,7 @@ class Connection implements DriverConnection ...@@ -691,7 +691,7 @@ class Connection implements DriverConnection
$stmt = new ResultCacheStatement($this->executeQuery($query, $params, $types), $resultCache, $cacheKey, $realKey, $qcp->getLifetime()); $stmt = new ResultCacheStatement($this->executeQuery($query, $params, $types), $resultCache, $cacheKey, $realKey, $qcp->getLifetime());
} }
$stmt->setFetchMode($this->_defaultFetchStyle); $stmt->setFetchMode($this->_defaultFetchMode);
return $stmt; return $stmt;
} }
...@@ -740,7 +740,7 @@ class Connection implements DriverConnection ...@@ -740,7 +740,7 @@ class Connection implements DriverConnection
} }
$statement = call_user_func_array(array($this->_conn, 'query'), $args); $statement = call_user_func_array(array($this->_conn, 'query'), $args);
$statement->setFetchMode($this->_defaultFetchStyle); $statement->setFetchMode($this->_defaultFetchMode);
if ($logger) { if ($logger) {
$logger->stopQuery(); $logger->stopQuery();
......
...@@ -29,7 +29,7 @@ class DB2Statement implements \IteratorAggregate, Statement ...@@ -29,7 +29,7 @@ class DB2Statement implements \IteratorAggregate, Statement
private $_bindParam = array(); private $_bindParam = array();
private $_defaultFetchStyle = \PDO::FETCH_BOTH; private $_defaultFetchMode = \PDO::FETCH_BOTH;
/** /**
* DB2_BINARY, DB2_CHAR, DB2_DOUBLE, or DB2_LONG * DB2_BINARY, DB2_CHAR, DB2_DOUBLE, or DB2_LONG
...@@ -148,9 +148,9 @@ class DB2Statement implements \IteratorAggregate, Statement ...@@ -148,9 +148,9 @@ class DB2Statement implements \IteratorAggregate, Statement
/** /**
* {@inheritdoc} * {@inheritdoc}
*/ */
public function setFetchMode($fetchStyle, $arg2 = null, $arg3 = null) public function setFetchMode($fetchMode, $arg2 = null, $arg3 = null)
{ {
$this->_defaultFetchStyle = $fetchStyle; $this->_defaultFetchMode = $fetchMode;
} }
/** /**
...@@ -165,10 +165,10 @@ class DB2Statement implements \IteratorAggregate, Statement ...@@ -165,10 +165,10 @@ class DB2Statement implements \IteratorAggregate, Statement
/** /**
* {@inheritdoc} * {@inheritdoc}
*/ */
public function fetch($fetchStyle = null) public function fetch($fetchMode = null)
{ {
$fetchStyle = $fetchStyle ?: $this->_defaultFetchStyle; $fetchMode = $fetchMode ?: $this->_defaultFetchMode;
switch ($fetchStyle) { switch ($fetchMode) {
case \PDO::FETCH_BOTH: case \PDO::FETCH_BOTH:
return db2_fetch_both($this->_stmt); return db2_fetch_both($this->_stmt);
case \PDO::FETCH_ASSOC: case \PDO::FETCH_ASSOC:
...@@ -176,17 +176,17 @@ class DB2Statement implements \IteratorAggregate, Statement ...@@ -176,17 +176,17 @@ class DB2Statement implements \IteratorAggregate, Statement
case \PDO::FETCH_NUM: case \PDO::FETCH_NUM:
return db2_fetch_array($this->_stmt); return db2_fetch_array($this->_stmt);
default: default:
throw new DB2Exception("Given Fetch-Style " . $fetchStyle . " is not supported."); throw new DB2Exception("Given Fetch-Style " . $fetchMode . " is not supported.");
} }
} }
/** /**
* {@inheritdoc} * {@inheritdoc}
*/ */
public function fetchAll($fetchStyle = null) public function fetchAll($fetchMode = null)
{ {
$rows = array(); $rows = array();
while ($row = $this->fetch($fetchStyle)) { while ($row = $this->fetch($fetchMode)) {
$rows[] = $row; $rows[] = $row;
} }
return $rows; return $rows;
......
...@@ -60,7 +60,7 @@ class MysqliStatement implements \IteratorAggregate, Statement ...@@ -60,7 +60,7 @@ class MysqliStatement implements \IteratorAggregate, Statement
*/ */
protected $_values = array(); protected $_values = array();
protected $_defaultFetchStyle = PDO::FETCH_BOTH; protected $_defaultFetchMode = PDO::FETCH_BOTH;
public function __construct(\mysqli $conn, $prepareString) public function __construct(\mysqli $conn, $prepareString)
{ {
...@@ -216,7 +216,7 @@ class MysqliStatement implements \IteratorAggregate, Statement ...@@ -216,7 +216,7 @@ class MysqliStatement implements \IteratorAggregate, Statement
/** /**
* {@inheritdoc} * {@inheritdoc}
*/ */
public function fetch($fetchStyle = null) public function fetch($fetchMode = null)
{ {
$values = $this->_fetch(); $values = $this->_fetch();
if (null === $values) { if (null === $values) {
...@@ -227,9 +227,9 @@ class MysqliStatement implements \IteratorAggregate, Statement ...@@ -227,9 +227,9 @@ class MysqliStatement implements \IteratorAggregate, Statement
throw new MysqliException($this->_stmt->error, $this->_stmt->errno); throw new MysqliException($this->_stmt->error, $this->_stmt->errno);
} }
$fetchStyle = $fetchStyle ?: $this->_defaultFetchStyle; $fetchMode = $fetchMode ?: $this->_defaultFetchMode;
switch ($fetchStyle) { switch ($fetchMode) {
case PDO::FETCH_NUM: case PDO::FETCH_NUM:
return $values; return $values;
...@@ -242,24 +242,24 @@ class MysqliStatement implements \IteratorAggregate, Statement ...@@ -242,24 +242,24 @@ class MysqliStatement implements \IteratorAggregate, Statement
return $ret; return $ret;
default: default:
throw new MysqliException("Unknown fetch type '{$fetchStyle}'"); throw new MysqliException("Unknown fetch type '{$fetchMode}'");
} }
} }
/** /**
* {@inheritdoc} * {@inheritdoc}
*/ */
public function fetchAll($fetchStyle = null) public function fetchAll($fetchMode = null)
{ {
$fetchStyle = $fetchStyle ?: $this->_defaultFetchStyle; $fetchMode = $fetchMode ?: $this->_defaultFetchMode;
$rows = array(); $rows = array();
if (PDO::FETCH_COLUMN == $fetchStyle) { if (PDO::FETCH_COLUMN == $fetchMode) {
while (($row = $this->fetchColumn()) !== false) { while (($row = $this->fetchColumn()) !== false) {
$rows[] = $row; $rows[] = $row;
} }
} else { } else {
while (($row = $this->fetch($fetchStyle)) !== null) { while (($row = $this->fetch($fetchMode)) !== null) {
$rows[] = $row; $rows[] = $row;
} }
} }
...@@ -328,7 +328,7 @@ class MysqliStatement implements \IteratorAggregate, Statement ...@@ -328,7 +328,7 @@ class MysqliStatement implements \IteratorAggregate, Statement
*/ */
public function setFetchMode($fetchMode, $arg2 = null, $arg3 = null) public function setFetchMode($fetchMode, $arg2 = null, $arg3 = null)
{ {
$this->_defaultFetchStyle = $fetchMode; $this->_defaultFetchMode = $fetchMode;
} }
/** /**
......
...@@ -79,7 +79,7 @@ class OCI8Connection implements \Doctrine\DBAL\Driver\Connection ...@@ -79,7 +79,7 @@ class OCI8Connection implements \Doctrine\DBAL\Driver\Connection
{ {
$args = func_get_args(); $args = func_get_args();
$sql = $args[0]; $sql = $args[0];
//$fetchStyle = $args[1]; //$fetchMode = $args[1];
$stmt = $this->prepare($sql); $stmt = $this->prepare($sql);
$stmt->execute(); $stmt->execute();
return $stmt; return $stmt;
......
...@@ -36,14 +36,14 @@ class OCI8Statement implements \IteratorAggregate, Statement ...@@ -36,14 +36,14 @@ class OCI8Statement implements \IteratorAggregate, Statement
protected $_sth; protected $_sth;
protected $_conn; protected $_conn;
protected static $_PARAM = ':param'; protected static $_PARAM = ':param';
protected static $fetchStyleMap = array( protected static $fetchModeMap = array(
PDO::FETCH_BOTH => OCI_BOTH, PDO::FETCH_BOTH => OCI_BOTH,
PDO::FETCH_ASSOC => OCI_ASSOC, PDO::FETCH_ASSOC => OCI_ASSOC,
PDO::FETCH_NUM => OCI_NUM, PDO::FETCH_NUM => OCI_NUM,
PDO::PARAM_LOB => OCI_B_BLOB, PDO::PARAM_LOB => OCI_B_BLOB,
PDO::FETCH_COLUMN => OCI_NUM, PDO::FETCH_COLUMN => OCI_NUM,
); );
protected $_defaultFetchStyle = PDO::FETCH_BOTH; protected $_defaultFetchMode = PDO::FETCH_BOTH;
protected $_paramMap = array(); protected $_paramMap = array();
/** /**
...@@ -190,9 +190,9 @@ class OCI8Statement implements \IteratorAggregate, Statement ...@@ -190,9 +190,9 @@ class OCI8Statement implements \IteratorAggregate, Statement
/** /**
* {@inheritdoc} * {@inheritdoc}
*/ */
public function setFetchMode($fetchStyle, $arg2 = null, $arg3 = null) public function setFetchMode($fetchMode, $arg2 = null, $arg3 = null)
{ {
$this->_defaultFetchStyle = $fetchStyle; $this->_defaultFetchMode = $fetchMode;
} }
/** /**
...@@ -207,41 +207,41 @@ class OCI8Statement implements \IteratorAggregate, Statement ...@@ -207,41 +207,41 @@ class OCI8Statement implements \IteratorAggregate, Statement
/** /**
* {@inheritdoc} * {@inheritdoc}
*/ */
public function fetch($fetchStyle = null) public function fetch($fetchMode = null)
{ {
$fetchStyle = $fetchStyle ?: $this->_defaultFetchStyle; $fetchMode = $fetchMode ?: $this->_defaultFetchMode;
if ( ! isset(self::$fetchStyleMap[$fetchStyle])) { if ( ! isset(self::$fetchModeMap[$fetchMode])) {
throw new \InvalidArgumentException("Invalid fetch style: " . $fetchStyle); throw new \InvalidArgumentException("Invalid fetch style: " . $fetchMode);
} }
return oci_fetch_array($this->_sth, self::$fetchStyleMap[$fetchStyle] | OCI_RETURN_NULLS | OCI_RETURN_LOBS); return oci_fetch_array($this->_sth, self::$fetchModeMap[$fetchMode] | OCI_RETURN_NULLS | OCI_RETURN_LOBS);
} }
/** /**
* {@inheritdoc} * {@inheritdoc}
*/ */
public function fetchAll($fetchStyle = null) public function fetchAll($fetchMode = null)
{ {
$fetchStyle = $fetchStyle ?: $this->_defaultFetchStyle; $fetchMode = $fetchMode ?: $this->_defaultFetchMode;
if ( ! isset(self::$fetchStyleMap[$fetchStyle])) { if ( ! isset(self::$fetchModeMap[$fetchMode])) {
throw new \InvalidArgumentException("Invalid fetch style: " . $fetchStyle); throw new \InvalidArgumentException("Invalid fetch style: " . $fetchMode);
} }
$result = array(); $result = array();
if (self::$fetchStyleMap[$fetchStyle] === OCI_BOTH) { if (self::$fetchModeMap[$fetchMode] === OCI_BOTH) {
while ($row = $this->fetch($fetchStyle)) { while ($row = $this->fetch($fetchMode)) {
$result[] = $row; $result[] = $row;
} }
} else { } else {
$fetchStructure = OCI_FETCHSTATEMENT_BY_ROW; $fetchStructure = OCI_FETCHSTATEMENT_BY_ROW;
if ($fetchStyle == PDO::FETCH_COLUMN) { if ($fetchMode == PDO::FETCH_COLUMN) {
$fetchStructure = OCI_FETCHSTATEMENT_BY_COLUMN; $fetchStructure = OCI_FETCHSTATEMENT_BY_COLUMN;
} }
oci_fetch_all($this->_sth, $result, 0, -1, oci_fetch_all($this->_sth, $result, 0, -1,
self::$fetchStyleMap[$fetchStyle] | OCI_RETURN_NULLS | $fetchStructure | OCI_RETURN_LOBS); self::$fetchModeMap[$fetchMode] | OCI_RETURN_NULLS | $fetchStructure | OCI_RETURN_LOBS);
if ($fetchStyle == PDO::FETCH_COLUMN) { if ($fetchMode == PDO::FETCH_COLUMN) {
$result = $result[0]; $result = $result[0];
} }
} }
......
...@@ -31,20 +31,20 @@ class PDOStatement extends \PDOStatement implements Statement ...@@ -31,20 +31,20 @@ class PDOStatement extends \PDOStatement implements Statement
{ {
private function __construct() {} private function __construct() {}
public function setFetchMode($fetchStyle, $arg2 = null, $arg3 = null) public function setFetchMode($fetchMode, $arg2 = null, $arg3 = null)
{ {
// This thin wrapper is necessary to shield against the weird signature // This thin wrapper is necessary to shield against the weird signature
// of PDOStatement::setFetchMode(): even if the second and third // of PDOStatement::setFetchMode(): even if the second and third
// parameters are optional, PHP will not let us remove it from this // parameters are optional, PHP will not let us remove it from this
// declaration. // declaration.
if ($arg2 === null && $arg3 === null) { if ($arg2 === null && $arg3 === null) {
return parent::setFetchMode($fetchStyle); return parent::setFetchMode($fetchMode);
} }
if ($arg3 === null) { if ($arg3 === null) {
return parent::setFetchMode($fetchStyle, $arg2); return parent::setFetchMode($fetchMode, $arg2);
} }
return parent::setFetchMode($fetchStyle, $arg2, $arg3); return parent::setFetchMode($fetchMode, $arg2, $arg3);
} }
} }
...@@ -50,32 +50,32 @@ interface ResultStatement extends \Traversable ...@@ -50,32 +50,32 @@ interface ResultStatement extends \Traversable
* setFetchMode * setFetchMode
* Set the fetch mode to use while iterating this statement. * Set the fetch mode to use while iterating this statement.
* *
* @param integer $fetchStyle * @param integer $fetchMode
*/ */
function setFetchMode($fetchStyle, $arg2 = null, $arg3 = null); function setFetchMode($fetchMode, $arg2 = null, $arg3 = null);
/** /**
* fetch * fetch
* *
* @see Query::HYDRATE_* constants * @see Query::HYDRATE_* constants
* @param integer $fetchStyle Controls how the next row will be returned to the caller. * @param integer $fetchMode Controls how the next row will be returned to the caller.
* This value must be one of the Query::HYDRATE_* constants, * This value must be one of the Query::HYDRATE_* constants,
* defaulting to Query::HYDRATE_BOTH * defaulting to Query::HYDRATE_BOTH
* *
* @return mixed * @return mixed
*/ */
function fetch($fetchStyle = null); function fetch($fetchMode = null);
/** /**
* Returns an array containing all of the result set rows * Returns an array containing all of the result set rows
* *
* @param integer $fetchStyle Controls how the next row will be returned to the caller. * @param integer $fetchMode Controls how the next row will be returned to the caller.
* This value must be one of the Query::HYDRATE_* constants, * This value must be one of the Query::HYDRATE_* constants,
* defaulting to Query::HYDRATE_BOTH * defaulting to Query::HYDRATE_BOTH
* *
* @return array * @return array
*/ */
function fetchAll($fetchStyle = null); function fetchAll($fetchMode = null);
/** /**
* fetchColumn * fetchColumn
......
...@@ -75,7 +75,7 @@ class SQLSrvStatement implements IteratorAggregate, Statement ...@@ -75,7 +75,7 @@ class SQLSrvStatement implements IteratorAggregate, Statement
* *
* @param int * @param int
*/ */
private $defaultFetchStyle = PDO::FETCH_BOTH; private $defaultFetchMode = PDO::FETCH_BOTH;
/** /**
* @var int|null * @var int|null
...@@ -175,9 +175,9 @@ class SQLSrvStatement implements IteratorAggregate, Statement ...@@ -175,9 +175,9 @@ class SQLSrvStatement implements IteratorAggregate, Statement
} }
} }
public function setFetchMode($fetchStyle, $arg2 = null, $arg3 = null) public function setFetchMode($fetchMode, $arg2 = null, $arg3 = null)
{ {
$this->defaultFetchStyle = $fetchStyle; $this->defaultFetchMode = $fetchMode;
} }
/** /**
...@@ -192,12 +192,12 @@ class SQLSrvStatement implements IteratorAggregate, Statement ...@@ -192,12 +192,12 @@ class SQLSrvStatement implements IteratorAggregate, Statement
/** /**
* {@inheritdoc} * {@inheritdoc}
*/ */
public function fetch($fetchStyle = null) public function fetch($fetchMode = null)
{ {
$fetchStyle = $fetchStyle ?: $this->defaultFetchStyle; $fetchMode = $fetchMode ?: $this->defaultFetchMode;
if (isset(self::$fetchMap[$fetchStyle])) { if (isset(self::$fetchMap[$fetchMode])) {
return sqlsrv_fetch_array($this->stmt, self::$fetchMap[$fetchStyle]); return sqlsrv_fetch_array($this->stmt, self::$fetchMap[$fetchMode]);
} else if ($fetchStyle == PDO::FETCH_OBJ || $fetchStyle == PDO::FETCH_CLASS) { } else if ($fetchMode == PDO::FETCH_OBJ || $fetchMode == PDO::FETCH_CLASS) {
$className = null; $className = null;
$ctorArgs = null; $ctorArgs = null;
if (func_num_args() >= 2) { if (func_num_args() >= 2) {
...@@ -214,7 +214,7 @@ class SQLSrvStatement implements IteratorAggregate, Statement ...@@ -214,7 +214,7 @@ class SQLSrvStatement implements IteratorAggregate, Statement
/** /**
* {@inheritdoc} * {@inheritdoc}
*/ */
public function fetchAll($fetchStyle = null) public function fetchAll($fetchMode = null)
{ {
$className = null; $className = null;
$ctorArgs = null; $ctorArgs = null;
...@@ -225,7 +225,7 @@ class SQLSrvStatement implements IteratorAggregate, Statement ...@@ -225,7 +225,7 @@ class SQLSrvStatement implements IteratorAggregate, Statement
} }
$rows = array(); $rows = array();
while ($row = $this->fetch($fetchStyle, $className, $ctorArgs)) { while ($row = $this->fetch($fetchMode, $className, $ctorArgs)) {
$rows[] = $row; $rows[] = $row;
} }
return $rows; return $rows;
......
...@@ -51,7 +51,7 @@ class Statement implements \IteratorAggregate, \Doctrine\DBAL\Driver\Statement ...@@ -51,7 +51,7 @@ class Statement implements \IteratorAggregate, \Doctrine\DBAL\Driver\Statement
/** /**
* @var int * @var int
*/ */
private $defaultFetchStyle = PDO::FETCH_BOTH; private $defaultFetchMode = PDO::FETCH_BOTH;
/** /**
* Wraps <tt>Statement</tt> and applies portability measures * Wraps <tt>Statement</tt> and applies portability measures
...@@ -101,10 +101,10 @@ class Statement implements \IteratorAggregate, \Doctrine\DBAL\Driver\Statement ...@@ -101,10 +101,10 @@ class Statement implements \IteratorAggregate, \Doctrine\DBAL\Driver\Statement
return $this->stmt->execute($params); return $this->stmt->execute($params);
} }
public function setFetchMode($fetchStyle, $arg1 = null, $arg2 = null) public function setFetchMode($fetchMode, $arg1 = null, $arg2 = null)
{ {
$this->defaultFetchStyle = $fetchStyle; $this->defaultFetchMode = $fetchMode;
$this->stmt->setFetchMode($fetchStyle, $arg1, $arg2); $this->stmt->setFetchMode($fetchMode, $arg1, $arg2);
} }
public function getIterator() public function getIterator()
...@@ -113,32 +113,32 @@ class Statement implements \IteratorAggregate, \Doctrine\DBAL\Driver\Statement ...@@ -113,32 +113,32 @@ class Statement implements \IteratorAggregate, \Doctrine\DBAL\Driver\Statement
return new \ArrayIterator($data); return new \ArrayIterator($data);
} }
public function fetch($fetchStyle = null) public function fetch($fetchMode = null)
{ {
$fetchStyle = $fetchStyle ?: $this->defaultFetchStyle; $fetchMode = $fetchMode ?: $this->defaultFetchMode;
$row = $this->stmt->fetch($fetchStyle); $row = $this->stmt->fetch($fetchMode);
$row = $this->fixRow($row, $row = $this->fixRow($row,
$this->portability & (Connection::PORTABILITY_EMPTY_TO_NULL|Connection::PORTABILITY_RTRIM), $this->portability & (Connection::PORTABILITY_EMPTY_TO_NULL|Connection::PORTABILITY_RTRIM),
!is_null($this->case) && ($fetchStyle == PDO::FETCH_ASSOC || $fetchStyle == PDO::FETCH_BOTH) && ($this->portability & Connection::PORTABILITY_FIX_CASE) !is_null($this->case) && ($fetchMode == PDO::FETCH_ASSOC || $fetchMode == PDO::FETCH_BOTH) && ($this->portability & Connection::PORTABILITY_FIX_CASE)
); );
return $row; return $row;
} }
public function fetchAll($fetchStyle = null, $columnIndex = 0) public function fetchAll($fetchMode = null, $columnIndex = 0)
{ {
$fetchStyle = $fetchStyle ?: $this->defaultFetchStyle; $fetchMode = $fetchMode ?: $this->defaultFetchMode;
if ($columnIndex != 0) { if ($columnIndex != 0) {
$rows = $this->stmt->fetchAll($fetchStyle, $columnIndex); $rows = $this->stmt->fetchAll($fetchMode, $columnIndex);
} else { } else {
$rows = $this->stmt->fetchAll($fetchStyle); $rows = $this->stmt->fetchAll($fetchMode);
} }
$iterateRow = $this->portability & (Connection::PORTABILITY_EMPTY_TO_NULL|Connection::PORTABILITY_RTRIM); $iterateRow = $this->portability & (Connection::PORTABILITY_EMPTY_TO_NULL|Connection::PORTABILITY_RTRIM);
$fixCase = !is_null($this->case) && ($fetchStyle == PDO::FETCH_ASSOC || $fetchStyle == PDO::FETCH_BOTH) && ($this->portability & Connection::PORTABILITY_FIX_CASE); $fixCase = !is_null($this->case) && ($fetchMode == PDO::FETCH_ASSOC || $fetchMode == PDO::FETCH_BOTH) && ($this->portability & Connection::PORTABILITY_FIX_CASE);
if ( ! $iterateRow && !$fixCase) { if ( ! $iterateRow && !$fixCase) {
return $rows; return $rows;
} }
......
...@@ -184,9 +184,9 @@ class Statement implements \IteratorAggregate, DriverStatement ...@@ -184,9 +184,9 @@ class Statement implements \IteratorAggregate, DriverStatement
return $this->stmt->errorInfo(); return $this->stmt->errorInfo();
} }
public function setFetchMode($fetchStyle, $arg2 = null, $arg3 = null) public function setFetchMode($fetchMode, $arg2 = null, $arg3 = null)
{ {
return $this->stmt->setFetchMode($fetchStyle, $arg2, $arg3); return $this->stmt->setFetchMode($fetchMode, $arg2, $arg3);
} }
public function getIterator() public function getIterator()
...@@ -197,28 +197,28 @@ class Statement implements \IteratorAggregate, DriverStatement ...@@ -197,28 +197,28 @@ class Statement implements \IteratorAggregate, DriverStatement
/** /**
* Fetches the next row from a result set. * Fetches the next row from a result set.
* *
* @param integer $fetchStyle * @param integer $fetchMode
* @return mixed The return value of this function on success depends on the fetch type. * @return mixed The return value of this function on success depends on the fetch type.
* In all cases, FALSE is returned on failure. * In all cases, FALSE is returned on failure.
*/ */
public function fetch($fetchStyle = null) public function fetch($fetchMode = null)
{ {
return $this->stmt->fetch($fetchStyle); return $this->stmt->fetch($fetchMode);
} }
/** /**
* Returns an array containing all of the result set rows. * Returns an array containing all of the result set rows.
* *
* @param integer $fetchStyle * @param integer $fetchMode
* @param mixed $fetchArgument * @param mixed $fetchArgument
* @return array An array containing all of the remaining rows in the result set. * @return array An array containing all of the remaining rows in the result set.
*/ */
public function fetchAll($fetchStyle = null, $fetchArgument = 0) public function fetchAll($fetchMode = null, $fetchArgument = 0)
{ {
if ($fetchArgument !== 0) { if ($fetchArgument !== 0) {
return $this->stmt->fetchAll($fetchStyle, $fetchArgument); return $this->stmt->fetchAll($fetchMode, $fetchArgument);
} }
return $this->stmt->fetchAll($fetchStyle); return $this->stmt->fetchAll($fetchMode);
} }
/** /**
......
...@@ -101,13 +101,13 @@ class ResultCacheTest extends \Doctrine\Tests\DbalFunctionalTestCase ...@@ -101,13 +101,13 @@ class ResultCacheTest extends \Doctrine\Tests\DbalFunctionalTestCase
$this->assertStandardAndIteratorFetchAreEqual(\PDO::FETCH_NUM); $this->assertStandardAndIteratorFetchAreEqual(\PDO::FETCH_NUM);
} }
public function assertStandardAndIteratorFetchAreEqual($fetchStyle) public function assertStandardAndIteratorFetchAreEqual($fetchMode)
{ {
$stmt = $this->_conn->executeQuery("SELECT * FROM caching ORDER BY test_int ASC", array(), array(), new QueryCacheProfile(10, "testcachekey")); $stmt = $this->_conn->executeQuery("SELECT * FROM caching ORDER BY test_int ASC", array(), array(), new QueryCacheProfile(10, "testcachekey"));
$data = $this->hydrateStmt($stmt, $fetchStyle); $data = $this->hydrateStmt($stmt, $fetchMode);
$stmt = $this->_conn->executeQuery("SELECT * FROM caching ORDER BY test_int ASC", array(), array(), new QueryCacheProfile(10, "testcachekey")); $stmt = $this->_conn->executeQuery("SELECT * FROM caching ORDER BY test_int ASC", array(), array(), new QueryCacheProfile(10, "testcachekey"));
$data_iterator = $this->hydrateStmtIterator($stmt, $fetchStyle); $data_iterator = $this->hydrateStmtIterator($stmt, $fetchMode);
$this->assertEquals($data, $data_iterator); $this->assertEquals($data, $data_iterator);
} }
...@@ -145,18 +145,18 @@ class ResultCacheTest extends \Doctrine\Tests\DbalFunctionalTestCase ...@@ -145,18 +145,18 @@ class ResultCacheTest extends \Doctrine\Tests\DbalFunctionalTestCase
$this->assertEquals(2, count($this->sqlLogger->queries)); $this->assertEquals(2, count($this->sqlLogger->queries));
} }
public function assertCacheNonCacheSelectSameFetchModeAreEqual($expectedResult, $fetchStyle) public function assertCacheNonCacheSelectSameFetchModeAreEqual($expectedResult, $fetchMode)
{ {
$stmt = $this->_conn->executeQuery("SELECT * FROM caching ORDER BY test_int ASC", array(), array(), new QueryCacheProfile(10, "testcachekey")); $stmt = $this->_conn->executeQuery("SELECT * FROM caching ORDER BY test_int ASC", array(), array(), new QueryCacheProfile(10, "testcachekey"));
$this->assertEquals(2, $stmt->columnCount()); $this->assertEquals(2, $stmt->columnCount());
$data = $this->hydrateStmt($stmt, $fetchStyle); $data = $this->hydrateStmt($stmt, $fetchMode);
$this->assertEquals($expectedResult, $data); $this->assertEquals($expectedResult, $data);
$stmt = $this->_conn->executeQuery("SELECT * FROM caching ORDER BY test_int ASC", array(), array(), new QueryCacheProfile(10, "testcachekey")); $stmt = $this->_conn->executeQuery("SELECT * FROM caching ORDER BY test_int ASC", array(), array(), new QueryCacheProfile(10, "testcachekey"));
$this->assertEquals(2, $stmt->columnCount()); $this->assertEquals(2, $stmt->columnCount());
$data = $this->hydrateStmt($stmt, $fetchStyle); $data = $this->hydrateStmt($stmt, $fetchMode);
$this->assertEquals($expectedResult, $data); $this->assertEquals($expectedResult, $data);
$this->assertEquals(1, count($this->sqlLogger->queries), "just one dbal hit"); $this->assertEquals(1, count($this->sqlLogger->queries), "just one dbal hit");
} }
...@@ -185,20 +185,20 @@ class ResultCacheTest extends \Doctrine\Tests\DbalFunctionalTestCase ...@@ -185,20 +185,20 @@ class ResultCacheTest extends \Doctrine\Tests\DbalFunctionalTestCase
$this->assertEquals(1, count($secondCache->fetch("emptycachekey"))); $this->assertEquals(1, count($secondCache->fetch("emptycachekey")));
} }
private function hydrateStmt($stmt, $fetchStyle = \PDO::FETCH_ASSOC) private function hydrateStmt($stmt, $fetchMode = \PDO::FETCH_ASSOC)
{ {
$data = array(); $data = array();
while ($row = $stmt->fetch($fetchStyle)) { while ($row = $stmt->fetch($fetchMode)) {
$data[] = is_array($row) ? array_change_key_case($row, CASE_LOWER) : $row; $data[] = is_array($row) ? array_change_key_case($row, CASE_LOWER) : $row;
} }
$stmt->closeCursor(); $stmt->closeCursor();
return $data; return $data;
} }
private function hydrateStmtIterator($stmt, $fetchStyle = \PDO::FETCH_ASSOC) private function hydrateStmtIterator($stmt, $fetchMode = \PDO::FETCH_ASSOC)
{ {
$data = array(); $data = array();
$stmt->setFetchMode($fetchStyle); $stmt->setFetchMode($fetchMode);
foreach ($stmt as $row) { foreach ($stmt as $row) {
$data[] = is_array($row) ? array_change_key_case($row, CASE_LOWER) : $row; $data[] = is_array($row) ? array_change_key_case($row, CASE_LOWER) : $row;
} }
......
...@@ -27,7 +27,7 @@ class HydratorMockStatement implements \Doctrine\DBAL\Driver\Statement ...@@ -27,7 +27,7 @@ class HydratorMockStatement implements \Doctrine\DBAL\Driver\Statement
* *
* @return array * @return array
*/ */
public function fetchAll($fetchStyle = null, $columnIndex = null, array $ctorArgs = null) public function fetchAll($fetchMode = null, $columnIndex = null, array $ctorArgs = null)
{ {
return $this->_resultSet; return $this->_resultSet;
} }
...@@ -44,7 +44,7 @@ class HydratorMockStatement implements \Doctrine\DBAL\Driver\Statement ...@@ -44,7 +44,7 @@ class HydratorMockStatement implements \Doctrine\DBAL\Driver\Statement
* Fetches the next row in the result set. * Fetches the next row in the result set.
* *
*/ */
public function fetch($fetchStyle = null) public function fetch($fetchMode = null)
{ {
$current = current($this->_resultSet); $current = current($this->_resultSet);
next($this->_resultSet); next($this->_resultSet);
......
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