-
Notifications
You must be signed in to change notification settings - Fork 67
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
Run SQL commands on connection #145
Comments
@langabi Thanks for reporting, makes a lot of sense and is indeed something we've already toyed around with! Similar requests have come up (perhaps indirectly) in #133 and others. Here's my concept for a future $db = new React\Mysql\MysqlClient('alice:secret@localhost/bookstore');
$db->on('open', fn () => $db->exec("SET time_zone = '+03:00'"));
$db->query('SELECT 1')->then(fn (QueryResult $result) => var_dump($result)); The idea is to fire the What do you think about this? |
I believe this has been answered, so I'm closing this for now. Please come back with more details if this problem persists and we can always reopen this 👍 |
Thanks! I don’t know how I missed your earlier comment, sorry! This looks perfect, and solves my use case. Thanks! |
Any news/progress on the 'open' event? I'd also need to SET the time_zone (to UTC) for any MySQL connection... |
I'm trying to run specific SQL queries at connection time, eg.
SET time_zone = '+03:00';
.Is there a way to do so that will re-run this query every time the connection is re-established? As far as I can see, no, because if one chains a ->then() onto the original LazyConnection or Connection, this will NOT be rerun if the connection closes and is reopened.
Alternatively, one could use an 'open' or 'connect' event, but it doesn't look like there is one.
Any good ideas? Thanks!
The text was updated successfully, but these errors were encountered: