|
2 | 2 | namespace Ubiquity\db\providers\swoole; |
3 | 3 |
|
4 | 4 | use Ubiquity\db\providers\AbstractDbWrapper; |
5 | | -use Swoole\Coroutine\MySQL; |
| 5 | +use Ubiquity\db\providers\TraitHasPool; |
6 | 6 |
|
7 | 7 | /** |
8 | 8 | * Ubiquity\db\providers\swoole$SwooleWrapper |
9 | 9 | * This class is part of Ubiquity |
10 | 10 | * @author jcheron <[email protected]> |
11 | | - * @version 1.0.1 |
| 11 | + * @version 1.0.0 |
12 | 12 | * @property \Swoole\Coroutine\MySQL $dbInstance |
13 | 13 | * |
14 | 14 | */ |
15 | 15 | class SwooleWrapper extends AbstractDbWrapper { |
| 16 | +use TraitHasPool; |
16 | 17 |
|
17 | 18 | private $inTransaction=false; |
18 | 19 |
|
19 | 20 | public function __construct($dbType = 'mysql') { |
20 | 21 | $this->quote = '`'; |
21 | 22 | } |
22 | 23 |
|
| 24 | + public function getPoolClass() { |
| 25 | + return \Ubiquity\db\pooling\ConnectionPool::class; |
| 26 | + } |
| 27 | + |
23 | 28 | public function queryColumn($sql, $columnNumber = null) { |
24 | 29 | $stmt = $this->getInstance()->prepare($sql); |
25 | 30 | if($stmt->execute()){ |
@@ -154,23 +159,5 @@ public function executeStatement($statement, array $values = null) { |
154 | 159 |
|
155 | 160 | public function getPrimaryKeys($tableName) {} |
156 | 161 |
|
157 | | - public function connect(string $dbType, $dbName, $serverName, string $port, string $user, string $password, array $options) { |
158 | | - $uid=\Swoole\Coroutine::getuid(); |
159 | | - if(!isset($this->dbInstance[$uid])){ |
160 | | - $db=new MySQL(); |
161 | | - $server = [ |
162 | | - 'charset' => 'utf8mb4', |
163 | | - 'timeout' => 1.000, |
164 | | - 'strict_type' => true |
165 | | - ]; |
166 | | - $db->connect(['host'=>$serverName??'127.0.0.1','port'=>$port??3306,'user'=>$user??'root','password'=>$password??'','database'=>$dbName??'']+$server); |
167 | | - $this->dbInstance[$uid]=$db; |
168 | | - } |
169 | | - } |
170 | | - |
171 | | - public function getDbInstance() { |
172 | | - return $this->dbInstance[\Swoole\Coroutine::getuid()]; |
173 | | - } |
174 | | - |
175 | 162 | } |
176 | 163 |
|
0 commit comments