Skip to content

Commit

Permalink
Normalize signature for ResultStatement::fetch()
Browse files Browse the repository at this point in the history
  • Loading branch information
phansys committed Oct 1, 2016
1 parent 23dab1a commit 6217f28
Show file tree
Hide file tree
Showing 7 changed files with 30 additions and 20 deletions.
2 changes: 1 addition & 1 deletion lib/Doctrine/DBAL/Cache/ArrayStatement.php
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ public function getIterator()
/**
* {@inheritdoc}
*/
public function fetch($fetchMode = null)
public function fetch($fetchMode = null, $cursorOrientation = \PDO::FETCH_ORI_NEXT, $cursorOffset = 0)
{
if (isset($this->data[$this->num])) {
$row = $this->data[$this->num++];
Expand Down
2 changes: 1 addition & 1 deletion lib/Doctrine/DBAL/Cache/ResultCacheStatement.php
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ public function getIterator()
/**
* {@inheritdoc}
*/
public function fetch($fetchMode = null)
public function fetch($fetchMode = null, $cursorOrientation = \PDO::FETCH_ORI_NEXT, $cursorOffset = 0)
{
if ($this->data === null) {
$this->data = array();
Expand Down
2 changes: 1 addition & 1 deletion lib/Doctrine/DBAL/Driver/OCI8/OCI8Statement.php
Original file line number Diff line number Diff line change
Expand Up @@ -255,7 +255,7 @@ public function getIterator()
/**
* {@inheritdoc}
*/
public function fetch($fetchMode = null)
public function fetch($fetchMode = null, $cursorOrientation = \PDO::FETCH_ORI_NEXT, $cursorOffset = 0)
{
$fetchMode = $fetchMode ?: $this->_defaultFetchMode;
if ( ! isset(self::$fetchModeMap[$fetchMode])) {
Expand Down
8 changes: 4 additions & 4 deletions lib/Doctrine/DBAL/Driver/PDOStatement.php
Original file line number Diff line number Diff line change
Expand Up @@ -97,18 +97,18 @@ public function execute($params = null)
/**
* {@inheritdoc}
*/
public function fetch($fetchMode = null, $cursorOrientation = null, $cursorOffset = null)
public function fetch($fetchMode = null, $cursorOrientation = \PDO::FETCH_ORI_NEXT, $cursorOffset = 0)
{
try {
if ($fetchMode === null && $cursorOrientation === null && $cursorOffset === null) {
if ($fetchMode === null && \PDO::FETCH_ORI_NEXT === $cursorOrientation && 0 === $cursorOffset) {
return parent::fetch();
}

if ($cursorOrientation === null && $cursorOffset === null) {
if (\PDO::FETCH_ORI_NEXT === $cursorOrientation && 0 === $cursorOffset) {
return parent::fetch($fetchMode);
}

if ($cursorOffset === null) {
if (0 === $cursorOffset) {
return parent::fetch($fetchMode, $cursorOrientation);
}

Expand Down
25 changes: 20 additions & 5 deletions lib/Doctrine/DBAL/Driver/ResultStatement.php
Original file line number Diff line number Diff line change
Expand Up @@ -58,16 +58,31 @@ public function setFetchMode($fetchMode, $arg2 = null, $arg3 = null);
/**
* Returns the next row of a result set.
*
* @param integer|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|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,
* this value determines which row will be returned to the caller.
* This value must be one of the \PDO::FETCH_ORI_* constants,
* defaulting to \PDO::FETCH_ORI_NEXT. To request a scrollable
* cursor for your ResultStatement object, you must set the \PDO::ATTR_CURSOR
* attribute to \PDO::CURSOR_SCROLL when you prepare the SQL statement with
* \PDO::prepare().
* @param int $cursorOffset For a ResultStatement object representing a scrollable cursor for which the
* cursorOrientation parameter is set to \PDO::FETCH_ORI_ABS, this value
* specifies the absolute number of the row in the result set that shall be
* fetched.
* For a ResultStatement object representing a scrollable cursor for which the
* cursorOrientation parameter is set to \PDO::FETCH_ORI_REL, this value
* specifies the row to fetch relative to the cursor position before
* ResultStatement::fetch() was called.
*
* @return mixed The return value of this method on success depends on the fetch mode. In all cases, FALSE is
* returned on failure.
*
* @see PDO::FETCH_* constants.
* @see \PDO::FETCH_* constants.
*/
public function fetch($fetchMode = null);
public function fetch($fetchMode = null, $cursorOrientation = \PDO::FETCH_ORI_NEXT, $cursorOffset = 0);

/**
* Returns an array containing all of the result set rows.
Expand Down
2 changes: 1 addition & 1 deletion lib/Doctrine/DBAL/Portability/Statement.php
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ public function getIterator()
/**
* {@inheritdoc}
*/
public function fetch($fetchMode = null)
public function fetch($fetchMode = null, $cursorOrientation = \PDO::FETCH_ORI_NEXT, $cursorOffset = 0)
{
$fetchMode = $fetchMode ?: $this->defaultFetchMode;

Expand Down
9 changes: 2 additions & 7 deletions lib/Doctrine/DBAL/Statement.php
Original file line number Diff line number Diff line change
Expand Up @@ -252,14 +252,9 @@ public function getIterator()
}

/**
* Fetches the next row from a result set.
*
* @param integer|null $fetchMode
*
* @return mixed The return value of this function on success depends on the fetch type.
* In all cases, FALSE is returned on failure.
* {@inheritdoc}
*/
public function fetch($fetchMode = null)
public function fetch($fetchMode = null, $cursorOrientation = \PDO::FETCH_ORI_NEXT, $cursorOffset = 0)
{
return $this->stmt->fetch($fetchMode);
}
Expand Down

0 comments on commit 6217f28

Please sign in to comment.