Completed
Push — master ( d6fc27...dc9f7f )
by Hung
19s
created

ResultSet::fetchAllAssoc()   A

Complexity

Conditions 4
Paths 4

Size

Total Lines 14
Code Lines 8

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
dl 0
loc 14
c 1
b 0
f 0
rs 9.2
cc 4
eloc 8
nc 4
nop 0
1
<?php
2
3
namespace Foolz\SphinxQL\Drivers\Mysqli;
4
5
use Foolz\SphinxQL\Exception\ConnectionException;
6
use Foolz\SphinxQL\Drivers\ResultSetBase;
7
8
class ResultSet extends ResultSetBase
9
{
10
    /**
11
     * @var Connection
12
     */
13
    protected $connection;
14
15
    /**
16
     * @var \mysqli_result
17
     */
18
    protected $result;
19
20
    /**
21
     * @param ResultSetAdapter $adapter
22
     * @param Connection $connection
23
     * @param null|\mysqli_result $result
24
     */
25
    public function __construct(ResultSetAdapter $adapter, Connection $connection, $result = null)
26
    {
27
        $this->connection = $connection;
28
        $this->adapter = $adapter;
29
        $this->result = $result;
30
        $this->init();
31
    }
32
33
    /**
34
     * @param Connection $connection
35
     * @param null|\mysqli_result $result
36
     * @return ResultSet
37
     */
38
    public static function make(Connection $connection, $result = null)
39
    {
40
        $adapter = new ResultSetAdapter($connection, $result);
41
        return new ResultSet($adapter, $connection, $result);
42
    }
43
44
    /**
45
     * Get the result object returned by PHP's MySQLi
46
     *
47
     * @return \mysqli_result
48
     *
49
     * @codeCoverageIgnore
50
     */
51
    public function getResultObject()
52
    {
53
        return $this->result;
54
    }
55
56
    /**
57
     * Get the MySQLi connection wrapper object
58
     *
59
     * @return Connection
60
     *
61
     * @codeCoverageIgnore
62
     */
63
    public function getConnection()
64
    {
65
        return $this->connection;
66
    }
67
68
    /**
69
     * Get the PHP MySQLi object
70
     *
71
     * @return \mysqli
72
     * @throws ConnectionException
73
     */
74
    public function getMysqliConnection()
75
    {
76
        return $this->connection->getConnection();
77
    }
78
}
79