Commit d2655e48 authored by Nicolas Grekas's avatar Nicolas Grekas

fix defaultFetchStyle not being considered everywhere

parent d55b9fbb
......@@ -58,14 +58,15 @@ class ArrayStatement implements \IteratorAggregate, ResultStatement
public function getIterator()
{
$data = $this->fetchAll($this->defaultFetchStyle);
$data = $this->fetchAll();
return new \ArrayIterator($data);
}
public function fetch($fetchStyle = PDO::FETCH_BOTH)
public function fetch($fetchStyle = null)
{
if (isset($this->data[$this->num])) {
$row = $this->data[$this->num++];
$fetchStyle = $fetchStyle ?: $this->defaultFetchStyle;
if ($fetchStyle === PDO::FETCH_ASSOC) {
return $row;
} else if ($fetchStyle === PDO::FETCH_NUM) {
......@@ -81,7 +82,7 @@ class ArrayStatement implements \IteratorAggregate, ResultStatement
return false;
}
public function fetchAll($fetchStyle = PDO::FETCH_BOTH)
public function fetchAll($fetchStyle = null)
{
$rows = array();
while ($row = $this->fetch($fetchStyle)) {
......
......@@ -139,7 +139,7 @@ class ResultCacheStatement implements \IteratorAggregate, ResultStatement
public function getIterator()
{
$data = $this->fetchAll($this->defaultFetchStyle);
$data = $this->fetchAll();
return new \ArrayIterator($data);
}
......@@ -153,7 +153,7 @@ class ResultCacheStatement implements \IteratorAggregate, ResultStatement
*
* @return mixed
*/
public function fetch($fetchStyle = PDO::FETCH_BOTH)
public function fetch($fetchStyle = null)
{
if ($this->data === null) {
$this->data = array();
......@@ -163,6 +163,8 @@ class ResultCacheStatement implements \IteratorAggregate, ResultStatement
if ($row) {
$this->data[] = $row;
$fetchStyle = $fetchStyle ?: $this->defaultFetchStyle;
if ($fetchStyle == PDO::FETCH_ASSOC) {
return $row;
} else if ($fetchStyle == PDO::FETCH_NUM) {
......@@ -188,7 +190,7 @@ class ResultCacheStatement implements \IteratorAggregate, ResultStatement
*
* @return array
*/
public function fetchAll($fetchStyle = PDO::FETCH_BOTH)
public function fetchAll($fetchStyle = null)
{
$rows = array();
while ($row = $this->fetch($fetchStyle)) {
......
......@@ -158,7 +158,7 @@ class DB2Statement implements \IteratorAggregate, Statement
*/
public function getIterator()
{
$data = $this->fetchAll($this->_defaultFetchStyle);
$data = $this->fetchAll();
return new \ArrayIterator($data);
}
......@@ -185,7 +185,6 @@ class DB2Statement implements \IteratorAggregate, Statement
*/
public function fetchAll($fetchStyle = null)
{
$fetchStyle = $fetchStyle ?: $this->_defaultFetchStyle;
$rows = array();
while ($row = $this->fetch($fetchStyle)) {
$rows[] = $row;
......
......@@ -253,18 +253,18 @@ class MysqliStatement implements \IteratorAggregate, Statement
{
$fetchStyle = $fetchStyle ?: $this->_defaultFetchStyle;
$a = array();
$rows = array();
if (PDO::FETCH_COLUMN == $fetchStyle) {
while (($value = $this->fetchColumn()) !== false) {
$a[] = $value;
while (($row = $this->fetchColumn()) !== false) {
$rows[] = $row;
}
} else {
while (($row = $this->fetch($fetchStyle)) !== null) {
$a[] = $row;
$rows[] = $row;
}
}
return $a;
return $rows;
}
/**
......@@ -336,7 +336,7 @@ class MysqliStatement implements \IteratorAggregate, Statement
*/
public function getIterator()
{
$data = $this->fetchAll($this->_defaultFetchStyle);
$data = $this->fetchAll();
return new \ArrayIterator($data);
}
}
......@@ -79,7 +79,7 @@ class OCI8Connection implements \Doctrine\DBAL\Driver\Connection
{
$args = func_get_args();
$sql = $args[0];
//$fetchMode = $args[1];
//$fetchStyle = $args[1];
$stmt = $this->prepare($sql);
$stmt->execute();
return $stmt;
......
......@@ -200,7 +200,7 @@ class OCI8Statement implements \IteratorAggregate, Statement
*/
public function getIterator()
{
$data = $this->fetchAll($this->_defaultFetchStyle);
$data = $this->fetchAll();
return new \ArrayIterator($data);
}
......
......@@ -64,7 +64,7 @@ interface ResultStatement extends \Traversable
*
* @return mixed
*/
function fetch($fetchStyle = PDO::FETCH_BOTH);
function fetch($fetchStyle = null);
/**
* Returns an array containing all of the result set rows
......@@ -75,7 +75,7 @@ interface ResultStatement extends \Traversable
*
* @return array
*/
function fetchAll($fetchStyle = PDO::FETCH_BOTH);
function fetchAll($fetchStyle = null);
/**
* fetchColumn
......
......@@ -185,7 +185,7 @@ class SQLSrvStatement implements IteratorAggregate, Statement
*/
public function getIterator()
{
$data = $this->fetchAll($this->defaultFetchStyle);
$data = $this->fetchAll();
return new \ArrayIterator($data);
}
......@@ -194,7 +194,7 @@ class SQLSrvStatement implements IteratorAggregate, Statement
*/
public function fetch($fetchStyle = null)
{
$fetchStyle = ($fetchStyle)?:$this->defaultFetchStyle;
$fetchStyle = $fetchStyle ?: $this->defaultFetchStyle;
if (isset(self::$fetchMap[$fetchStyle])) {
return sqlsrv_fetch_array($this->stmt, self::$fetchMap[$fetchStyle]);
} else if ($fetchStyle == PDO::FETCH_OBJ || $fetchStyle == PDO::FETCH_CLASS) {
......
......@@ -109,12 +109,14 @@ class Statement implements \IteratorAggregate, \Doctrine\DBAL\Driver\Statement
public function getIterator()
{
$data = $this->fetchAll($this->defaultFetchStyle);
$data = $this->fetchAll();
return new \ArrayIterator($data);
}
public function fetch($fetchStyle = PDO::FETCH_BOTH)
public function fetch($fetchStyle = null)
{
$fetchStyle = $fetchStyle ?: $this->defaultFetchStyle;
$row = $this->stmt->fetch($fetchStyle);
$row = $this->fixRow($row,
......@@ -125,8 +127,10 @@ class Statement implements \IteratorAggregate, \Doctrine\DBAL\Driver\Statement
return $row;
}
public function fetchAll($fetchStyle = PDO::FETCH_BOTH, $columnIndex = 0)
public function fetchAll($fetchStyle = null, $columnIndex = 0)
{
$fetchStyle = $fetchStyle ?: $this->defaultFetchStyle;
if ($columnIndex != 0) {
$rows = $this->stmt->fetchAll($fetchStyle, $columnIndex);
} else {
......
......@@ -201,7 +201,7 @@ class Statement implements \IteratorAggregate, DriverStatement
* @return mixed The return value of this function on success depends on the fetch type.
* In all cases, FALSE is returned on failure.
*/
public function fetch($fetchStyle = PDO::FETCH_BOTH)
public function fetch($fetchStyle = null)
{
return $this->stmt->fetch($fetchStyle);
}
......@@ -213,7 +213,7 @@ class Statement implements \IteratorAggregate, DriverStatement
* @param mixed $fetchArgument
* @return array An array containing all of the remaining rows in the result set.
*/
public function fetchAll($fetchStyle = PDO::FETCH_BOTH, $fetchArgument = 0)
public function fetchAll($fetchStyle = null, $fetchArgument = 0)
{
if ($fetchArgument !== 0) {
return $this->stmt->fetchAll($fetchStyle, $fetchArgument);
......
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