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

Add queryStream() method to stream result set rows and remove undocumented "results" event #57

Merged
merged 2 commits into from
Jun 20, 2018

Conversation

clue
Copy link
Contributor

@clue clue commented Jun 20, 2018

This PR adds a new queryStream() method which allows processing larger result sets with hundreds or thousands of records, so that one is no longer limited by memory in how many records can be processed. Its API can be used like this:

$stream = $connection->queryStream('SELECT * FROM users');

$stream->on('data', function ($row) {
    var_dump($row);
});
$stream->on('end', function () {
    echo 'DONE' . PHP_EOL;
});

Being a new addition to the ConnectionInterface, this PR is technically a BC break. This also includes a small patch to ensure that results are no longer buffered internally in the Parser and removes its undocumented results event. Empirical evidence suggests this should not affect most consumers.

Builds on top of #54
Resolves / closes #50

@clue clue added this to the v0.4.0 milestone Jun 20, 2018
@WyriHaximus WyriHaximus merged commit 967ed25 into friends-of-reactphp:master Jun 20, 2018
@clue clue deleted the stream branch June 20, 2018 19:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Support streaming result sets
3 participants