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

QueryDataReader::createItem() shold be realized in Db\Query class #50

Open
Tigrov opened this issue Apr 16, 2024 · 0 comments
Open

QueryDataReader::createItem() shold be realized in Db\Query class #50

Tigrov opened this issue Apr 16, 2024 · 0 comments

Comments

@Tigrov
Copy link
Member

Tigrov commented Apr 16, 2024

QueryDataReader::createItem() method should be removed

protected function createItem(array|object $row): array|object
{
/** @psalm-var TValue */
return $row;
}

BatchQueryResult already has property Closure $populateMethod to prepare row result

https://github.com/yiisoft/db/blob/e380ae2ffb6f3a466e6f168fafa93548e50f0d8c/src/Query/BatchQueryResult.php#L109

Instead of these, Db\Query class can contain property Closure $callback (and withCallback() method) which will be called for each row from result.

The $callback will be specified in one place (Query) instead of many different realizations. And this will allow to use Query directly to get prepared result (without any data reader).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant