|
14 | 14 | use Swoft\Db\AbstractDbConnection;
|
15 | 15 | use Swoft\Db\Bean\Annotation\Connection;
|
16 | 16 | use Swoft\Db\Exception\MysqlException;
|
| 17 | +use Swoft\Db\Pool\Config\DbPoolProperties; |
17 | 18 | use Swoole\Coroutine\Mysql;
|
18 | 19 |
|
19 | 20 | /**
|
@@ -59,17 +60,29 @@ public function createConnection()
|
59 | 60 | $options = $this->parseUri($uri);
|
60 | 61 | $options['timeout'] = $this->pool->getTimeout();
|
61 | 62 |
|
| 63 | + /** @var DbPoolProperties $config */ |
| 64 | + $config = $this->pool->getPoolConfig(); |
| 65 | + $strictType = $config->isStrictType(); |
| 66 | + $fetchMode = $config->isFetchMode(); |
| 67 | + |
| 68 | + $serverConfig = [ |
| 69 | + 'host' => $options['host'], |
| 70 | + 'port' => $options['port'], |
| 71 | + 'user' => $options['user'], |
| 72 | + 'password' => $options['password'], |
| 73 | + 'database' => $options['database'], |
| 74 | + 'timeout' => $options['timeout'], |
| 75 | + 'charset' => $options['charset'], |
| 76 | + 'strict_type' => $strictType, |
| 77 | + ]; |
| 78 | + |
| 79 | + if (version_compare(swoole_version(), '4.0', '>=')) { |
| 80 | + $serverConfig['fetch_mode'] = $fetchMode; |
| 81 | + } |
| 82 | + |
62 | 83 | // init
|
63 | 84 | $mysql = new MySQL();
|
64 |
| - $mysql->connect([ |
65 |
| - 'host' => $options['host'], |
66 |
| - 'port' => $options['port'], |
67 |
| - 'user' => $options['user'], |
68 |
| - 'password' => $options['password'], |
69 |
| - 'database' => $options['database'], |
70 |
| - 'timeout' => $options['timeout'], |
71 |
| - 'charset' => $options['charset'], |
72 |
| - ]); |
| 85 | + $mysql->connect($serverConfig); |
73 | 86 |
|
74 | 87 | // error
|
75 | 88 | if ($mysql->connected === false) {
|
|
0 commit comments