Removed Connection::project()

The methods has more limitations and caveats than provides real use:

1. It fetches all data in memory which is often inefficient (see #2718).
2. It fetches rows in memory one by one instead of using `fetchAll()`.
4. It doesn't allow to specify the statement fetch mode since it's instantiated internally.
5. It can be easily replaced with:
   ```php
   foreach ($conn->executeQuery($query, $params, $types) as $value) {
      yield $function($value);
   }
   ```
parent e0a92b05
...@@ -103,6 +103,7 @@ Table columns are no longer indexed by column name. Use the `name` attribute of ...@@ -103,6 +103,7 @@ Table columns are no longer indexed by column name. Use the `name` attribute of
- The following methods have been removed as leaking internal implementation details: `::getHost()`, `::getPort()`, `::getUsername()`, `::getPassword()`. - The following methods have been removed as leaking internal implementation details: `::getHost()`, `::getPort()`, `::getUsername()`, `::getPassword()`.
- The `::getDatabase()` method can now return null which means that no database is currently selected. - The `::getDatabase()` method can now return null which means that no database is currently selected.
- The `::project()` method has been removed. Use `::executeQuery()` and fetch the data from the statement using one of the `Statement::fetch*()` methods instead.
## BC BREAK: Changes in `Doctrine\DBAL\Driver\SQLSrv\LastInsertId` ## BC BREAK: Changes in `Doctrine\DBAL\Driver\SQLSrv\LastInsertId`
......
...@@ -868,32 +868,6 @@ class Connection implements DriverConnection ...@@ -868,32 +868,6 @@ class Connection implements DriverConnection
return $stmt; return $stmt;
} }
/**
* Executes an, optionally parametrized, SQL query and returns the result,
* applying a given projection/transformation function on each row of the result.
*
* @param string $query The SQL query to execute.
* @param array<int, mixed>|array<string, mixed> $params The parameters, if any.
* @param Closure $function The transformation function that is applied on each row.
* The function receives a single parameter, an array, that
* represents a row of the result set.
*
* @return array<int, mixed> The projected result of the query.
*/
public function project(string $query, array $params, Closure $function) : array
{
$result = [];
$stmt = $this->executeQuery($query, $params);
while ($row = $stmt->fetch()) {
$result[] = $function($row);
}
$stmt->closeCursor();
return $result;
}
/** /**
* {@inheritDoc} * {@inheritDoc}
*/ */
......
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