Passed
Push — main ( c086bb...449bda )
by Thierry
01:40
created

ConnectionTrait::query()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 1
nc 1
nop 2
dl 0
loc 3
rs 10
c 1
b 0
f 0
1
<?php
2
3
namespace Lagdo\DbAdmin\Driver;
4
5
use Lagdo\DbAdmin\Driver\Entity\ConfigEntity;
6
use Lagdo\DbAdmin\Driver\Entity\TableFieldEntity;
7
8
use Lagdo\DbAdmin\Driver\Db\StatementInterface;
9
10
trait ConnectionTrait
11
{
12
    /**
13
     * Get the server description
14
     *
15
     * @return string
16
     */
17
    public function serverInfo()
18
    {
19
        return $this->connection->serverInfo();
20
    }
21
22
    /**
23
     * Get the driver extension
24
     *
25
     * @return string
26
     */
27
    public function extension()
28
    {
29
        return $this->connection->extension();
30
    }
31
32
    /**
33
     * Sets the client character set
34
     *
35
     * @param string $charset
36
     *
37
     * @return bool
38
     */
39
    public function setCharset(string $charset)
40
    {
41
        return $this->connection->setCharset($charset);
42
    }
43
44
    /**
45
     * Return a quoted string
46
     *
47
     * @param string $string
48
     *
49
     * @return string
50
     */
51
    public function quote(string $string)
52
    {
53
        return $this->connection->quote($string);
54
    }
55
56
    /**
57
     * Return a quoted string
58
     *
59
     * @param string $string
60
     *
61
     * @return string
62
     */
63
    public function quoteBinary(string $string)
64
    {
65
        return $this->connection->quoteBinary($string);
66
    }
67
68
    /**
69
     * Execute a query on the current database
70
     *
71
     * @param string $query
72
     * @param bool $unbuffered
73
     *
74
     * @return StatementInterface|bool
75
     */
76
    public function query(string $query, bool $unbuffered = false)
77
    {
78
        return $this->connection->query($query, $unbuffered);
79
    }
80
81
    /**
82
     * Get the number of rows affected by the last query
83
     *
84
     * @return integer
85
     */
86
    public function affectedRows()
87
    {
88
        return $this->connection->affectedRows();
89
    }
90
91
    /**
92
     * Execute a query on the current database and fetch the specified field
93
     *
94
     * @param string $query
95
     * @param int $field
96
     *
97
     * @return mixed
98
     */
99
    public function result(string $query, int $field = -1)
100
    {
101
        return $this->connection->result($query, $field);
102
    }
103
104
    /**
105
     * Execute a query on the current database and store the result
106
     *
107
     * @param string $query
108
     *
109
     * @return bool
110
     */
111
    public function multiQuery(string $query)
112
    {
113
        return $this->connection->multiQuery($query);
114
    }
115
116
    /**
117
     * Get the result saved by the multiQuery() method
118
     *
119
     * @return StatementInterface|null
120
     */
121
    public function storedResult()
122
    {
123
        return $this->connection->storedResult();
124
    }
125
126
    /**
127
     * Get the next row set of the last query
128
     *
129
     * @return bool
130
     */
131
    public function nextResult()
132
    {
133
        return $this->connection->nextResult();
134
    }
135
136
    /**
137
     * Convert value returned by database to actual value
138
     *
139
     * @param string|resource|null $value
140
     * @param TableFieldEntity $field
141
     *
142
     * @return string
143
     */
144
    public function value($value, TableFieldEntity $field)
145
    {
146
        return $this->connection->value($value, $field);
147
    }
148
}
149