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 8f331e81
# Upgrade to 3.0
## BC BREAK `Statement::project()` has been removed
- The `Statement::project()` method has been removed. Use `::executeQuery()` and fetch the data from the statement using one of the `Statement::fetch*()` methods instead.
## BC BREAK `::errorCode()` and `::errorInfo()` removed from `Connection` and `Statement` APIs
The error information is available in `DriverException` thrown in case of an error.
......
......@@ -1187,34 +1187,6 @@ class Connection implements DriverConnection
return $stmt;
}
/**
* Executes an, optionally parametrized, SQL query and returns the result,
* applying a given projection/transformation function on each row of the result.
*
* @deprecated
*
* @param string $query The SQL query to execute.
* @param 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 mixed[] The projected result of the query.
*/
public function project($query, array $params, Closure $function)
{
$result = [];
$stmt = $this->executeQuery($query, $params);
while ($row = $stmt->fetch()) {
$result[] = $function($row);
}
$stmt->closeCursor();
return $result;
}
public function query(string $sql) : ResultStatement
{
$connection = $this->getWrappedConnection();
......
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