Commit 611f975f authored by Christophe Coevoet's avatar Christophe Coevoet

Fixed the DB2Statement for the interface change

parent 7101ecd7
......@@ -21,12 +21,16 @@
namespace Doctrine\DBAL\Driver\IBMDB2;
class DB2Statement implements \Doctrine\DBAL\Driver\Statement
use \Doctrine\DBAL\Driver\Statement;
class DB2Statement implements \IteratorAggregate, Statement
{
private $_stmt = null;
private $_bindParam = array();
private $_defaultFetchStyle = \PDO::FETCH_BOTH;
/**
* DB2_BINARY, DB2_CHAR, DB2_DOUBLE, or DB2_LONG
* @var <type>
......@@ -196,6 +200,23 @@ class DB2Statement implements \Doctrine\DBAL\Driver\Statement
return $retval;
}
/**
* {@inheritdoc}
*/
public function setFetchMode($fetchStyle = \PDO::FETCH_BOTH)
{
$this->_defaultFetchStyle = $fetchStyle;
}
/**
* {@inheritdoc}
*/
public function getIterator()
{
$data = $this->fetchAll($this->_defaultFetchStyle);
return new \ArrayIterator($data);
}
/**
* fetch
*
......@@ -223,8 +244,9 @@ class DB2Statement implements \Doctrine\DBAL\Driver\Statement
*
* @return mixed
*/
function fetch($fetchStyle = \PDO::FETCH_BOTH)
public function fetch($fetchStyle = null)
{
$fetchStyle = $fetchStyle ?: $this->_defaultFetchStyle;
switch ($fetchStyle) {
case \PDO::FETCH_BOTH:
return db2_fetch_both($this->_stmt);
......@@ -249,8 +271,9 @@ class DB2Statement implements \Doctrine\DBAL\Driver\Statement
*
* @return array
*/
function fetchAll($fetchStyle = \PDO::FETCH_BOTH)
public function fetchAll($fetchStyle = null)
{
$fetchStyle = $fetchStyle ?: $this->_defaultFetchStyle;
$rows = array();
while ($row = $this->fetch($fetchStyle)) {
$rows[] = $row;
......
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