Unverified Commit fcde5f5f authored by Sergei Morozov's avatar Sergei Morozov

Merge pull request #3483 from morozov/row-count

Moved rowCount() from Statement to ResultStatement
parents 045fbe80 eeb88d5e
# Upgrade to 3.0
## BC BREAK `Statement::rowCount()` is moved.
`Statement::rowCount()` has been moved to the `ResultStatement` interface where it belongs by definition.
## BC BREAK Transaction-related `Statement` methods return `void`.
`Statement::beginTransaction()`, `::commit()` and `::rollBack()` no longer return a boolean value. They will throw a `DriverException` in case of failure.
......@@ -61,7 +65,7 @@ The following classes have been removed:
* `Doctrine\DBAL\Platforms\SQLAnywhere11Platform`
* `Doctrine\DBAL\Platforms\SQLAnywhere12Platform`
* `Doctrine\DBAL\Platforms\SQLAnywhere16Platform`
* `Doctrine\DBAL\Platforms\SQLAnywhere16Platform`
* `Doctrine\DBAL\Platforms\Keywords\SQLAnywhere11Keywords`
* `Doctrine\DBAL\Platforms\Keywords\SQLAnywhere12Keywords`
* `Doctrine\DBAL\Platforms\Keywords\SQLAnywhere16Keywords`
......
......@@ -57,6 +57,18 @@ class ArrayStatement implements IteratorAggregate, ResultStatement
return $this->columnCount;
}
/**
* {@inheritdoc}
*/
public function rowCount() : int
{
if ($this->data === null) {
return 0;
}
return count($this->data);
}
/**
* {@inheritdoc}
*/
......
......@@ -6,14 +6,12 @@ use ArrayIterator;
use Doctrine\Common\Cache\Cache;
use Doctrine\DBAL\DBALException;
use Doctrine\DBAL\Driver\ResultStatement;
use Doctrine\DBAL\Driver\Statement;
use Doctrine\DBAL\FetchMode;
use InvalidArgumentException;
use IteratorAggregate;
use function array_key_exists;
use function array_merge;
use function array_values;
use function assert;
use function count;
use function reset;
......@@ -214,8 +212,6 @@ class ResultCacheStatement implements IteratorAggregate, ResultStatement
*/
public function rowCount() : int
{
assert($this->statement instanceof Statement);
return $this->statement->rowCount();
}
}
......@@ -25,6 +25,17 @@ interface ResultStatement extends Traversable
*/
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;
/**
* Sets the fetch mode to use while iterating this statement.
*
......
......@@ -88,17 +88,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