| Total Complexity | 10 |
| Total Lines | 51 |
| Duplicated Lines | 0 % |
| Changes | 0 | ||
| 1 | <?php |
||
| 8 | class CoroutineMySQL |
||
| 9 | { |
||
| 10 | protected $coMySQL; |
||
| 11 | |||
| 12 | public function __construct() |
||
| 13 | { |
||
| 14 | $this->coMySQL = new SwooleMySQL(); |
||
| 15 | } |
||
| 16 | |||
| 17 | public function connect(array $serverInfo) |
||
| 18 | { |
||
| 19 | $this->coMySQL->connect($serverInfo); |
||
| 20 | } |
||
| 21 | |||
| 22 | public function prepare($sql) |
||
| 23 | { |
||
| 24 | $oldStatement = $this->coMySQL->prepare($sql); |
||
| 25 | if ($oldStatement === false) { |
||
|
|
|||
| 26 | throw new QueryException($sql, [], new \Exception($this->coMySQL->error, $this->coMySQL->errno)); |
||
| 27 | } |
||
| 28 | return new CoroutineMySQLStatement($oldStatement); |
||
| 29 | } |
||
| 30 | |||
| 31 | public function beginTransaction() |
||
| 32 | { |
||
| 33 | return $this->coMySQL->begin(); |
||
| 34 | } |
||
| 35 | |||
| 36 | public function commit() |
||
| 37 | { |
||
| 38 | return $this->coMySQL->commit(); |
||
| 39 | } |
||
| 40 | |||
| 41 | public function rollBack() |
||
| 42 | { |
||
| 43 | return $this->coMySQL->rollback(); |
||
| 44 | } |
||
| 45 | |||
| 46 | public function query($sql, $timeout = 0.0) |
||
| 47 | { |
||
| 48 | return $this->coMySQL->query($sql, $timeout); |
||
| 49 | } |
||
| 50 | |||
| 51 | public function lastInsertId() |
||
| 52 | { |
||
| 53 | return $this->coMySQL->insert_id; |
||
| 54 | } |
||
| 55 | |||
| 56 | public function rowCount() |
||
| 59 | } |
||
| 60 | } |