Unverified Commit 74eca6ba authored by Sergei Morozov's avatar Sergei Morozov Committed by GitHub

Merge pull request #4035 from morozov/row-count

Moved rowCount() from Statement to ResultStatement
parents 72e219a7 5df51cb3
# 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.
......
......@@ -50,6 +50,15 @@ class ArrayStatement implements ResultStatement
return $this->columnCount;
}
public function rowCount() : int
{
if ($this->data === null) {
return 0;
}
return count($this->data);
}
/**
* {@inheritdoc}
*/
......
......@@ -94,6 +94,11 @@ class ResultCacheStatement implements ResultStatement
return $this->statement->columnCount();
}
public function rowCount() : int
{
return $this->statement->rowCount();
}
/**
* {@inheritdoc}
*/
......
......@@ -25,6 +25,17 @@ interface ResultStatement
*/
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.
*
......
......@@ -72,17 +72,4 @@ interface Statement extends ResultStatement
* @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;
}
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