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

CoroutineMySQLStatement::execute()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 7
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 2
eloc 4
nc 2
nop 2
dl 0
loc 7
rs 9.4285
c 0
b 0
f 0
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
}