1 | <?php |
||
15 | class Database |
||
16 | { |
||
17 | /** @var \PDO Database driver */ |
||
18 | protected $driver; |
||
19 | |||
20 | /** @var string Database name */ |
||
21 | protected $database; |
||
22 | |||
23 | /** @var int Amount of milliseconds spent on queries */ |
||
24 | protected $elapsed; |
||
25 | |||
26 | /** @var int Amount queries executed */ |
||
27 | protected $count; |
||
28 | |||
29 | /** |
||
30 | * Connect to a database using driver with parameters |
||
31 | * @param string $database Database name |
||
32 | * @param string $username Database username |
||
33 | * @param string $password Database password |
||
34 | * @param string $host Database host(localhost by default) |
||
35 | * @param int $port Database port(3306 by default) |
||
36 | * @param string $driver Database driver for interaction(MySQL by default) |
||
37 | * @param string $charset Database character set |
||
38 | * @return bool True if connection to database was successful |
||
39 | */ |
||
40 | public function connect( |
||
62 | |||
63 | /** |
||
64 | * Get database name |
||
65 | * @return string |
||
66 | */ |
||
67 | public function database() |
||
71 | |||
72 | /** |
||
73 | * Get entity query manager |
||
74 | * @param string $entity Entity identifier |
||
75 | * @return Query Query manager instance |
||
76 | */ |
||
77 | public function manager($entity) |
||
81 | |||
82 | /** |
||
83 | * Intreal error beautifier |
||
84 | * @param \Exception $e |
||
85 | * @param $sql |
||
86 | */ |
||
87 | private function outputError(\Exception $e, $sql, $text = 'Error executing database query:') |
||
95 | |||
96 | /** |
||
97 | * Proxy function for executing database fetching logic with exception, |
||
98 | * error, profile handling |
||
99 | * @param callback $fetcher Callback for fetching |
||
100 | * @return mixed Fetching function result |
||
101 | */ |
||
102 | private function execute($fetcher) |
||
130 | |||
131 | /** |
||
132 | * High-level database query executor |
||
133 | * @param string $sql SQL statement |
||
134 | * @return mixed Database query result |
||
135 | */ |
||
136 | private function innerQuery($sql) |
||
145 | |||
146 | /** |
||
147 | * Retrieve array of records from a database, if $className is passed method |
||
148 | * will try to create an object of that type. If request has failed than |
||
149 | * method will return empty array of stdClass all arrays regarding to $className is |
||
150 | * passed or not. |
||
151 | * |
||
152 | * @param string $sql Query text |
||
153 | * @return array Collection of arrays or objects |
||
154 | */ |
||
155 | private function innerFetch($sql, $className = null) |
||
168 | |||
169 | /** |
||
170 | * Special accelerated function to retrieve db record fields instead of objects |
||
171 | * |
||
172 | * @param string $className |
||
173 | * @param mixed $query |
||
174 | * @param string $field |
||
175 | * |
||
176 | * @return array |
||
177 | */ |
||
178 | private function innerFetchColumn($className, $query, $field) |
||
194 | |||
195 | /** |
||
196 | * High-level database query executor |
||
197 | * @param string $sql SQL statement |
||
198 | * @return mixed Database query result |
||
199 | */ |
||
200 | public function query($sql) |
||
204 | |||
205 | /** |
||
206 | * Retrieve array of records from a database, if $className is passed method |
||
207 | * will try to create an object of that type. If request has failed than |
||
208 | * method will return empty array of stdClass all arrays regarding to $className is |
||
209 | * passed or not. |
||
210 | * |
||
211 | * @param string $sql Query text |
||
212 | * @return array Collection of arrays or objects |
||
213 | */ |
||
214 | public function fetch($sql) |
||
218 | |||
219 | /** |
||
220 | * Special accelerated function to retrieve db record fields instead of objects |
||
221 | * |
||
222 | * @param string $className |
||
223 | * @param mixed $query |
||
224 | * @param string $field |
||
225 | * |
||
226 | * @return array |
||
227 | */ |
||
228 | public function fetchColumn($className, $query, $field) |
||
232 | |||
233 | public function create($className, &$object = null) |
||
246 | |||
247 | public function update($className, &$object) |
||
254 | |||
255 | public function delete($className, &$object) |
||
261 | |||
262 | /** Count query result */ |
||
263 | public function count($className, $query) |
||
273 | |||
274 | /** |
||
275 | * Выполнить защиту значения поля для его безопасного использования в запросах |
||
276 | * |
||
277 | * @param string $value Значения поля для запроса |
||
278 | * @return string $value Безопасное представление значения поля для запроса |
||
279 | */ |
||
280 | protected function protectQueryValue($value) |
||
293 | |||
294 | /** |
||
295 | * Prepare create & update SQL statements fields |
||
296 | * @param string $className Entity name |
||
297 | * @param Record $object Database object to get values(if needed) |
||
298 | * @param bool $straight Way of forming SQL field statements |
||
299 | * @return array Collection of key => value with SQL fields statements |
||
300 | */ |
||
301 | protected function &getQueryFields($className, & $object = null, $straight = false) |
||
331 | |||
332 | /** @deprecated Use query() */ |
||
333 | public function &simple_query($sql) |
||
337 | } |
||
338 |
Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.
Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..