swoole / library

📚 Swoole Library
https://wiki.swoole.com/#/library
Apache License 2.0
237 stars 58 forks source link

mysql set_opt should be called before connecting #34

Closed zsxsoft closed 4 years ago

zsxsoft commented 4 years ago

https://github.com/swoole/library/blob/0f250bc7e7451992e0de103f07b284996feba07f/src/core/Database/MysqliPool.php

In current version, set_opt called after connect so none of these options work. This should be replaced with:

$mysqli = new mysqli();
foreach ($this->config->getOptions() as $option => $value) {
    $mysqli->set_opt($option, $value);
}
$mysqli->real_connect(....);