Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Moved rowCount() from Statement to ResultStatement #4035

Merged
merged 1 commit into from
May 28, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions UPGRADE.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Upgrade to 3.0

## BC BREAK `Statement::rowCount()` is moved.

`Statement::rowCount()` has been moved to the `ResultStatement` interface where it belongs by definition.

## Removed `FetchMode` and the corresponding methods

1. The `FetchMode` class and the `setFetchMode()` method of the `Connection` and `Statement` interfaces are removed.
Expand Down
9 changes: 9 additions & 0 deletions src/Cache/ArrayStatement.php
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,15 @@ public function columnCount()
return $this->columnCount;
}

public function rowCount() : int
{
if ($this->data === null) {
return 0;
}

return count($this->data);
}

/**
* {@inheritdoc}
*/
Expand Down
5 changes: 5 additions & 0 deletions src/Cache/ResultCacheStatement.php
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,11 @@ public function columnCount()
return $this->statement->columnCount();
}

public function rowCount() : int
{
return $this->statement->rowCount();
}

/**
* {@inheritdoc}
*/
Expand Down
11 changes: 11 additions & 0 deletions src/Driver/ResultStatement.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,17 @@ public function closeCursor();
*/
public function columnCount();

/**
* Returns the number of rows affected by the last DELETE, INSERT, or UPDATE statement
* executed by the corresponding object.
*
* If the last SQL statement executed by the associated Statement object was a SELECT statement,
* some databases may return the number of rows returned by that statement. However,
* this behaviour is not guaranteed for all databases and should not be
* relied on for portable applications.
*/
public function rowCount() : int;

/**
* Returns the next row of a result set as a numeric array or FALSE if there are no more rows.
*
Expand Down
13 changes: 0 additions & 13 deletions src/Driver/Statement.php
Original file line number Diff line number Diff line change
Expand Up @@ -72,17 +72,4 @@ public function bindParam($column, &$variable, $type = ParameterType::STRING, $l
* @return bool TRUE on success or FALSE on failure.
*/
public function execute($params = null);

/**
* Returns the number of rows affected by the last DELETE, INSERT, or UPDATE statement
* executed by the corresponding object.
*
* If the last SQL statement executed by the associated Statement object was a SELECT statement,
* some databases may return the number of rows returned by that statement. However,
* this behaviour is not guaranteed for all databases and should not be
* relied on for portable applications.
*
* @return int The number of rows.
*/
public function rowCount() : int;
}