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

Support streaming result sets #50

Closed
clue opened this issue Jun 15, 2018 · 0 comments · Fixed by #57
Closed

Support streaming result sets #50

clue opened this issue Jun 15, 2018 · 0 comments · Fixed by #57
Assignees
Milestone

Comments

@clue
Copy link
Contributor

clue commented Jun 15, 2018

Currently, the API only supports buffering the whole result set in memory. This makes sense for smaller result sets as working with an in-memory data structure with some dozens or hundreds of records works perfectly fine.

However, when processing larger result sets with hundreds or thousands of records, it would make sense to use a streaming approach so that one is no longer limited by memory in how many records can be processed.

I have prepared a working prototype that works really well. This will involve some minor BC breaks and also requires some API cleanup first, so I'm putting this out here as a heads-up.

Eventual API will use ReactPHP's existing stream API and could look something like this:

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

$stream->on('data', function ($row) {
    var_dump($row);
});
$stream->on('end', function () {
    echo 'DONE' . PHP_EOL;
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
1 participant