Skip to content

Commit

Permalink
Update statement for some drivers
Browse files Browse the repository at this point in the history
  • Loading branch information
phansys committed Feb 19, 2017
1 parent 2174f12 commit 93b3848
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 15 deletions.
12 changes: 6 additions & 6 deletions lib/Doctrine/DBAL/Driver/IBMDB2/DB2Statement.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ class DB2Statement implements \IteratorAggregate, Statement
/**
* @var resource
*/
private $_stmt = null;
private $_stmt;

/**
* @var array
Expand Down Expand Up @@ -147,8 +147,8 @@ public function errorCode()
public function errorInfo()
{
return array(
0 => db2_stmt_errormsg(),
1 => db2_stmt_error(),
db2_stmt_errormsg(),
db2_stmt_error(),
);
}

Expand Down Expand Up @@ -207,7 +207,7 @@ public function getIterator()
/**
* {@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
Expand Down Expand Up @@ -243,14 +243,14 @@ public function fetch($fetchMode = null)
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();

Expand Down
2 changes: 1 addition & 1 deletion lib/Doctrine/DBAL/Driver/ResultStatement.php
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ public function setFetchMode($fetchMode, $arg2 = null, $arg3 = null);
/**
* 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,
Expand Down
4 changes: 2 additions & 2 deletions lib/Doctrine/DBAL/Driver/SQLAnywhere/SQLAnywhereStatement.php
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,7 @@ public function execute($params = null)
*
* @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;
Expand Down Expand Up @@ -235,7 +235,7 @@ public function fetch($fetchMode = null)
/**
* {@inheritdoc}
*/
public function fetchAll($fetchMode = null)
public function fetchAll($fetchMode = null, $fetchArgument = null, $ctorArgs = null)
{
$rows = array();

Expand Down
14 changes: 8 additions & 6 deletions lib/Doctrine/DBAL/Driver/SQLSrv/SQLSrvStatement.php
Original file line number Diff line number Diff line change
Expand Up @@ -257,7 +257,7 @@ private function prepare()
$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,
Expand Down Expand Up @@ -302,8 +302,10 @@ public function getIterator()

/**
* {@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
Expand All @@ -318,25 +320,25 @@ public function fetch($fetchMode = null)
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();

Expand Down

0 comments on commit 93b3848

Please sign in to comment.