Completed
Push — master ( 8f800b...a10bf5 )
by Biao
03:46
created

CoroutineMySQLStatement   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 33
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
dl 0
loc 33
rs 10
c 0
b 0
f 0
wmc 5

4 Methods

Rating   Name   Duplication   Size   Complexity  
A rowCount() 0 3 1
A execute() 0 7 2
A __construct() 0 3 1
A fetchAll() 0 3 1
1
<?php
2
3
namespace Hhxsv5\LaravelS\Illuminate\Database;
4
5
use Swoole\Coroutine\MySQL\Statement as SwooleStatement;
6
7
class CoroutineMySQLStatement
8
{
9
    protected $statement;
10
    protected $result;
11
12
    public function __construct(SwooleStatement $statement)
13
    {
14
        $this->statement = $statement;
15
    }
16
17
    public function rowCount()
18
    {
19
        return $this->statement->affected_rows;
20
    }
21
22
    /**
23
     * @param array $params
24
     * @param int $timeout
25
     * @return bool
26
     * @throws StatementException
27
     */
28
    public function execute(array $params = [], $timeout = -1)
29
    {
30
        $this->result = $this->statement->execute($params, $timeout);
31
        if ($this->statement->errno != 0) {
32
            throw new StatementException($this->statement->error, $this->statement->errno);
33
        }
34
        return true;
35
    }
36
37
    public function fetchAll()
38
    {
39
        return $this->result;
40
    }
41
}