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

Removed Connection::project() #3823

Merged
merged 1 commit into from
Jan 16, 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
1 change: 1 addition & 0 deletions UPGRADE.md
Original file line number Diff line number Diff line change
Expand Up @@ -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 `::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`

Expand Down
26 changes: 0 additions & 26 deletions lib/Doctrine/DBAL/Connection.php
Original file line number Diff line number Diff line change
Expand Up @@ -868,32 +868,6 @@ public function executeCacheQuery(string $query, array $params, array $types, Qu
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}
*/
Expand Down