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
/**
* @var resource
*/
private $_stmt = null;
private $_stmt;
/**
* @var array
......@@ -147,8 +147,8 @@ class DB2Statement implements \IteratorAggregate, Statement
public function errorInfo()
{
return array(
0 => db2_stmt_errormsg(),
1 => db2_stmt_error(),
db2_stmt_errormsg(),
db2_stmt_error(),
);
}
......@@ -207,7 +207,7 @@ class DB2Statement implements \IteratorAggregate, Statement
/**
* {@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
// in order to prevent exceptional situation
......@@ -243,14 +243,14 @@ class DB2Statement implements \IteratorAggregate, Statement
case \PDO::FETCH_OBJ:
return db2_fetch_object($this->_stmt);
default:
throw new DB2Exception("Given Fetch-Style " . $fetchMode . " is not supported.");
throw new DB2Exception('Given Fetch-Style ' . $fetchMode . ' is not supported.');
}
}
/**
* {@inheritdoc}
*/
public function fetchAll($fetchMode = null)
public function fetchAll($fetchMode = null, $fetchArgument = null, $ctorArgs = null)
{
$rows = array();
......
......@@ -58,7 +58,7 @@ interface ResultStatement extends \Traversable
/**
* 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,
* defaulting to \PDO::FETCH_BOTH.
* @param int $cursorOrientation For a ResultStatement object representing a scrollable cursor,
......
......@@ -193,7 +193,7 @@ class SQLAnywhereStatement implements IteratorAggregate, Statement
*
* @throws SQLAnywhereException
*/
public function fetch($fetchMode = null)
public function fetch($fetchMode = null, $cursorOrientation = \PDO::FETCH_ORI_NEXT, $cursorOffset = 0)
{
if ( ! is_resource($this->result)) {
return false;
......@@ -235,7 +235,7 @@ class SQLAnywhereStatement implements IteratorAggregate, Statement
/**
* {@inheritdoc}
*/
public function fetchAll($fetchMode = null)
public function fetchAll($fetchMode = null, $fetchArgument = null, $ctorArgs = null)
{
$rows = array();
......
......@@ -257,7 +257,7 @@ class SQLSrvStatement implements IteratorAggregate, Statement
$params = array();
foreach ($this->variables as $column => &$variable) {
if ($this->types[$column] === \PDO::PARAM_LOB) {
if (PDO::PARAM_LOB === $this->types[$column]) {
$params[$column - 1] = array(
&$variable,
SQLSRV_PARAM_IN,
......@@ -302,8 +302,10 @@ class SQLSrvStatement implements IteratorAggregate, Statement
/**
* {@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
// in order to prevent exceptional situation
......@@ -318,25 +320,25 @@ class SQLSrvStatement implements IteratorAggregate, Statement
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;
$ctorArgs = $this->defaultFetchClassCtorArgs;
if (count($args) >= 2) {
$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;
}
throw new SQLSrvException("Fetch mode is not supported!");
throw new SQLSrvException('Fetch mode is not supported!');
}
/**
* {@inheritdoc}
*/
public function fetchAll($fetchMode = null)
public function fetchAll($fetchMode = null, $fetchArgument = null, $ctorArgs = null)
{
$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