Commit 5c80649f authored by Javier Spagnoletti's avatar Javier Spagnoletti

Update statement for some drivers

parent 003f1e23
...@@ -26,7 +26,7 @@ class DB2Statement implements \IteratorAggregate, Statement ...@@ -26,7 +26,7 @@ class DB2Statement implements \IteratorAggregate, Statement
/** /**
* @var resource * @var resource
*/ */
private $_stmt = null; private $_stmt;
/** /**
* @var array * @var array
...@@ -147,8 +147,8 @@ class DB2Statement implements \IteratorAggregate, Statement ...@@ -147,8 +147,8 @@ class DB2Statement implements \IteratorAggregate, Statement
public function errorInfo() public function errorInfo()
{ {
return array( return array(
0 => db2_stmt_errormsg(), db2_stmt_errormsg(),
1 => db2_stmt_error(), db2_stmt_error(),
); );
} }
...@@ -207,7 +207,7 @@ class DB2Statement implements \IteratorAggregate, Statement ...@@ -207,7 +207,7 @@ class DB2Statement implements \IteratorAggregate, Statement
/** /**
* {@inheritdoc} * {@inheritdoc}
*/ */
public function fetch($fetchMode = null) public function fetch($fetchMode = null, $cursorOrientation = \PDO::FETCH_ORI_NEXT, $cursorOffset = 0)
{ {
// do not try fetching from the statement if it's not expected to contain result // do not try fetching from the statement if it's not expected to contain result
// in order to prevent exceptional situation // in order to prevent exceptional situation
...@@ -243,14 +243,14 @@ class DB2Statement implements \IteratorAggregate, Statement ...@@ -243,14 +243,14 @@ class DB2Statement implements \IteratorAggregate, Statement
case \PDO::FETCH_OBJ: case \PDO::FETCH_OBJ:
return db2_fetch_object($this->_stmt); return db2_fetch_object($this->_stmt);
default: default:
throw new DB2Exception("Given Fetch-Style " . $fetchMode . " is not supported."); throw new DB2Exception('Given Fetch-Style ' . $fetchMode . ' is not supported.');
} }
} }
/** /**
* {@inheritdoc} * {@inheritdoc}
*/ */
public function fetchAll($fetchMode = null) public function fetchAll($fetchMode = null, $fetchArgument = null, $ctorArgs = null)
{ {
$rows = array(); $rows = array();
......
...@@ -58,7 +58,7 @@ interface ResultStatement extends \Traversable ...@@ -58,7 +58,7 @@ interface ResultStatement extends \Traversable
/** /**
* Returns the next row of a result set. * Returns the next row of a result set.
* *
* * @param int|null $fetchMode Controls how the next row will be returned to the caller. * @param int|null $fetchMode Controls how the next row will be returned to the caller.
* The value must be one of the \PDO::FETCH_* constants, * The value must be one of the \PDO::FETCH_* constants,
* defaulting to \PDO::FETCH_BOTH. * defaulting to \PDO::FETCH_BOTH.
* @param int $cursorOrientation For a ResultStatement object representing a scrollable cursor, * @param int $cursorOrientation For a ResultStatement object representing a scrollable cursor,
......
...@@ -193,7 +193,7 @@ class SQLAnywhereStatement implements IteratorAggregate, Statement ...@@ -193,7 +193,7 @@ class SQLAnywhereStatement implements IteratorAggregate, Statement
* *
* @throws SQLAnywhereException * @throws SQLAnywhereException
*/ */
public function fetch($fetchMode = null) public function fetch($fetchMode = null, $cursorOrientation = \PDO::FETCH_ORI_NEXT, $cursorOffset = 0)
{ {
if ( ! is_resource($this->result)) { if ( ! is_resource($this->result)) {
return false; return false;
...@@ -235,7 +235,7 @@ class SQLAnywhereStatement implements IteratorAggregate, Statement ...@@ -235,7 +235,7 @@ class SQLAnywhereStatement implements IteratorAggregate, Statement
/** /**
* {@inheritdoc} * {@inheritdoc}
*/ */
public function fetchAll($fetchMode = null) public function fetchAll($fetchMode = null, $fetchArgument = null, $ctorArgs = null)
{ {
$rows = array(); $rows = array();
......
...@@ -257,7 +257,7 @@ class SQLSrvStatement implements IteratorAggregate, Statement ...@@ -257,7 +257,7 @@ class SQLSrvStatement implements IteratorAggregate, Statement
$params = array(); $params = array();
foreach ($this->variables as $column => &$variable) { foreach ($this->variables as $column => &$variable) {
if ($this->types[$column] === \PDO::PARAM_LOB) { if (PDO::PARAM_LOB === $this->types[$column]) {
$params[$column - 1] = array( $params[$column - 1] = array(
&$variable, &$variable,
SQLSRV_PARAM_IN, SQLSRV_PARAM_IN,
...@@ -302,8 +302,10 @@ class SQLSrvStatement implements IteratorAggregate, Statement ...@@ -302,8 +302,10 @@ class SQLSrvStatement implements IteratorAggregate, Statement
/** /**
* {@inheritdoc} * {@inheritdoc}
*
* @throws SQLSrvException
*/ */
public function fetch($fetchMode = null) public function fetch($fetchMode = null, $cursorOrientation = PDO::FETCH_ORI_NEXT, $cursorOffset = 0)
{ {
// do not try fetching from the statement if it's not expected to contain result // do not try fetching from the statement if it's not expected to contain result
// in order to prevent exceptional situation // in order to prevent exceptional situation
...@@ -318,25 +320,25 @@ class SQLSrvStatement implements IteratorAggregate, Statement ...@@ -318,25 +320,25 @@ class SQLSrvStatement implements IteratorAggregate, Statement
return sqlsrv_fetch_array($this->stmt, self::$fetchMap[$fetchMode]) ?: false; return sqlsrv_fetch_array($this->stmt, self::$fetchMap[$fetchMode]) ?: false;
} }
if ($fetchMode == PDO::FETCH_OBJ || $fetchMode == PDO::FETCH_CLASS) { if (in_array($fetchMode, array(PDO::FETCH_OBJ, PDO::FETCH_CLASS), true)) {
$className = $this->defaultFetchClass; $className = $this->defaultFetchClass;
$ctorArgs = $this->defaultFetchClassCtorArgs; $ctorArgs = $this->defaultFetchClassCtorArgs;
if (count($args) >= 2) { if (count($args) >= 2) {
$className = $args[1]; $className = $args[1];
$ctorArgs = (isset($args[2])) ? $args[2] : array(); $ctorArgs = isset($args[2]) ? $args[2] : array();
} }
return sqlsrv_fetch_object($this->stmt, $className, $ctorArgs) ?: false; return sqlsrv_fetch_object($this->stmt, $className, $ctorArgs) ?: false;
} }
throw new SQLSrvException("Fetch mode is not supported!"); throw new SQLSrvException('Fetch mode is not supported!');
} }
/** /**
* {@inheritdoc} * {@inheritdoc}
*/ */
public function fetchAll($fetchMode = null) public function fetchAll($fetchMode = null, $fetchArgument = null, $ctorArgs = null)
{ {
$rows = array(); $rows = array();
......
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