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

simple mysql pool #176

Closed
wants to merge 1 commit into from
Closed

simple mysql pool #176

wants to merge 1 commit into from

Conversation

wpjscc
Copy link

@wpjscc wpjscc commented Jun 4, 2023

Hi ,this pr add a simple mysql pool

query

use React\MySQL\Pool;
use React\MySQL\QueryResult;

$pool = new Pool('test:test@localhost/test');

$pool->query($sql, $params)->then(function (QueryResult $command) {
          
            if (isset($command->resultRows)) {
                // this is a response to a SELECT etc. with some rows (0+)
                print_r($command->resultFields);
                print_r($command->resultRows);
                echo count($command->resultRows) . ' row(s) in set' . PHP_EOL;
            } else {
                // this is an OK message in response to an UPDATE etc.
                if ($command->insertId !== 0) {
                    var_dump('last insert ID', $command->insertId);
                }
                echo 'Query OK, ' . $command->affectedRows . ' row(s) affected' . PHP_EOL;
            }
        }, function (\Exception $error) {
            // the query was not executed successfully
            echo 'Error: ' . $error->getMessage() . PHP_EOL;
        });

query stream

use React\MySQL\Pool;

$pool = new Pool('test:test@localhost/test');
$stream = $pool->queryStream($sql, $params);
 $stream->on('data', function ($row) {
        print_r($row);
  });
    $stream->on('error', function ($err) {
        echo 'Error: ' . $err->getMessage() . PHP_EOL;
    });
    $stream->on('end', function () {
        echo 'Completed:'. PHP_EOL;
    });

@SimonFrings
Copy link
Contributor

Hey @wpjscc, thanks for opening this PR 👍

To give you an update, we're currently starting to work on a solution for the MySQL connection pool feature as I described in #175 (comment).

There seems to be a lot of overlap between your suggested changes and our vision for a connection pool, definitely some good input in here. In addition to implementing the feature itself, we also need multiple tests to assure the pool feature works as expected and some documentation to describe its usage, which is currently missing from this PR.

As I said, we're also working on this feature, so I think it makes sense that we invest time to add the necessary tests and documentation and create a separate pull request to add the connection pool. This is why I think we can close this pull request here and wait for our upcoming PR to get this feature in.

Thanks again for your work on this 🚀

@SimonFrings SimonFrings closed this Nov 3, 2023
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.

2 participants