Passed
Push — master ( 010f10...4d41a0 )
by Joe
02:48
created

Db::fetchObject()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 3
CRAP Score 1

Importance

Changes 0
Metric Value
cc 1
eloc 2
nc 1
nop 0
dl 0
loc 3
ccs 3
cts 3
cp 1
crap 1
rs 10
c 0
b 0
f 0
1
<?php
2
/**
3
 * MySQL Related Functionality
4
 * @author Joe Huss <[email protected]>
5
 * @copyright 2018
6
 * @package MyAdmin
7
 * @category SQL
8
 */
9
10
namespace MyDb\Mysqli;
11
12
use \MyDb\Generic;
13
use \MyDb\Db_Interface;
14
15
/**
16
 * Db
17
 *
18
 * @access public
19
 */
20
class Db extends Generic implements Db_Interface {
21
	/**
22
	 * @var string
23
	 */
24
	public $type = 'mysqli';
25
26
	/**
27
	 * alias function of select_db, changes the database we are working with.
28
	 *
29
	 * @param string $database the name of the database to use
30
	 * @return void
31
	 */
32 1
	public function useDb($database) {
33 1
		$this->selectDb($database);
34
	}
35
36
	/**
37
	 * changes the database we are working with.
38
	 *
39
	 * @param string $database the name of the database to use
40
	 * @return void
41
	 */
42 1
	public function selectDb($database) {
43 1
		$this->connect();
44 1
		mysqli_select_db($this->linkId, $database);
0 ignored issues
show
Bug introduced by
$this->linkId of type integer is incompatible with the type mysqli expected by parameter $link of mysqli_select_db(). ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

44
		mysqli_select_db(/** @scrutinizer ignore-type */ $this->linkId, $database);
Loading history...
45
	}
46
47
	/* public: connection management */
48
49
	/**
50
	 * Db::connect()
51
	 * @param string $database
52
	 * @param string $host
53
	 * @param string $user
54
	 * @param string $password
55
	 * @return int|\mysqli
56
	 */
57 14
	public function connect($database = '', $host = '', $user = '', $password = '') {
58
		/* Handle defaults */
59 14
		if ($database == '')
60 14
			$database = $this->database;
61 14
		if ($host == '')
62 14
			$host = $this->host;
63 14
		if ($user == '')
64 14
			$user = $this->user;
65 14
		if ($password == '')
66 14
			$password = $this->password;
67
		/* establish connection, select database */
68 14
		if (!is_object($this->linkId)) {
0 ignored issues
show
introduced by
The condition is_object($this->linkId) is always false.
Loading history...
69 14
			$this->connectionAttempt++;
70 14
			if ($this->connectionAttempt > 1)
71 3
				error_log("MySQLi Connection Attempt #{$this->connectionAttempt}/{$this->maxConnectErrors}");
72 14
			if ($this->connectionAttempt >= $this->maxConnectErrors) {
73
				$this->halt("connect($host, $user, \$password) failed. ".$mysqli->connect_error);
0 ignored issues
show
Comprehensibility Best Practice introduced by
The variable $mysqli seems to be never defined.
Loading history...
74
				return 0;
75
			}
76 14
			$this->linkId = mysqli_init();
77 14
			$this->linkId->options(MYSQLI_INIT_COMMAND, "SET NAMES {$this->characterSet} COLLATE {$this->collation}, COLLATION_CONNECTION = {$this->collation}, COLLATION_DATABASE = {$this->collation}");
78 14
			$this->linkId->real_connect($host, $user, $password, $database);
79 14
			$this->linkId->set_charset($this->characterSet);
80 14
			if ($this->linkId->connect_errno) {
81
				$this->halt("connect($host, $user, \$password) failed. ".$mysqli->connect_error);
82
				return 0;
83
			}
84
		}
85 14
		return $this->linkId;
86
	}
87
88
	/**
89
	 * Db::disconnect()
90
	 * @return bool
91
	 */
92
	public function disconnect() {
93
		$return = is_resource($this->linkId) ? $this->linkId->close() : false;
0 ignored issues
show
introduced by
The condition is_resource($this->linkId) is always false.
Loading history...
94
		$this->linkId = 0;
95
		return $return;
96
	}
97
98
	/**
99
	 * @param $string
100
	 * @return string
101
	 */
102 1
	public function real_escape($string) {
103 1
		if ((!is_resource($this->linkId) || $this->linkId == 0) && !$this->connect())
0 ignored issues
show
introduced by
The condition is_resource($this->linkId) is always false.
Loading history...
104
			return $this->escape($string);
105 1
		return mysqli_real_escape_string($this->linkId, $string);
106
	}
107
108
	/**
109
	 * @param $string
110
	 * @return string
111
	 */
112 1
	public function escape($string) {
113
		//if (function_exists('mysql_escape_string'))
114
			//return mysql_escape_string($string);
115 1
		return str_replace(array('\\', "\0", "\n", "\r", "'", '"', "\x1a"), array('\\\\', '\\0', '\\n', '\\r', "\\'", '\\"', '\\Z'), $string);
116
	}
117
118
	/**
119
	 * Db::dbAddslashes()
120
	 * @param mixed $str
121
	 * @return string
122
	 */
123 1
	public function dbAddslashes($str = '') {
124 1
		if ($str == '')
125 1
			return '';
126 1
		return addslashes($str);
127
	}
128
129
	/* public: discard the query result */
130
131
	/**
132
	 * Db::free()
133
	 * @return void
134
	 */
135 1
	public function free() {
136 1
		if (is_resource($this->queryId))
0 ignored issues
show
introduced by
The condition is_resource($this->queryId) is always false.
Loading history...
137
			@mysqli_free_result($this->queryId);
0 ignored issues
show
Security Best Practice introduced by
It seems like you do not handle an error condition for mysqli_free_result(). This can introduce security issues, and is generally not recommended. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-unhandled  annotation

137
			/** @scrutinizer ignore-unhandled */ @mysqli_free_result($this->queryId);

If you suppress an error, we recommend checking for the error condition explicitly:

// For example instead of
@mkdir($dir);

// Better use
if (@mkdir($dir) === false) {
    throw new \RuntimeException('The directory '.$dir.' could not be created.');
}
Loading history...
138 1
		$this->queryId = 0;
139
	}
140
141
	/**
142
	 * Db::queryReturn()
143
	 *
144
	 * Sends an SQL query to the server like the normal query() command but iterates through
145
	 * any rows and returns the row or rows immediately or FALSE on error
146
	 *
147
	 * @param mixed $query SQL Query to be used
148
	 * @param string $line optionally pass __LINE__ calling the query for logging
149
	 * @param string $file optionally pass __FILE__ calling the query for logging
150
	 * @return mixed FALSE if no rows, if a single row it returns that, if multiple it returns an array of rows, associative responses only
151
	 */
152 1
	public function queryReturn($query, $line = '', $file = '') {
153 1
		$this->query($query, $line, $file);
154 1
		if ($this->num_rows() == 0) {
155 1
			return false;
156 1
		} elseif ($this->num_rows() == 1) {
157 1
			$this->next_record(MYSQLI_ASSOC);
158 1
			return $this->Record;
159
		} else {
160 1
			$out = [];
161 1
			while ($this->next_record(MYSQLI_ASSOC))
162 1
				$out[] = $this->Record;
163 1
			return $out;
164
		}
165
	}
166
167
	/**
168
	 * db:qr()
169
	 *
170
	 *  alias of queryReturn()
171
	 *
172
	 * @param mixed $query SQL Query to be used
173
	 * @param string $line optionally pass __LINE__ calling the query for logging
174
	 * @param string $file optionally pass __FILE__ calling the query for logging
175
	 * @return mixed FALSE if no rows, if a single row it returns that, if multiple it returns an array of rows, associative responses only
176
	 */
177 1
	public function qr($query, $line = '', $file = '') {
178 1
		return $this->queryReturn($query, $line, $file);
179
	}
180
181
	/**
182
	 * creates a prepaired statement from query
183
	 *
184
	 * @param string $query sql wuery like INSERT INTO table (col) VALUES (?)  or  SELECT * from table WHERE col1 = ? and col2 = ?  or  UPDATE table SET col1 = ?, col2 = ? WHERE col3 = ?
185
	 * @return int|\MyDb\Mysqli\mysqli_stmt
0 ignored issues
show
Bug introduced by
The type MyDb\Mysqli\mysqli_stmt was not found. Did you mean mysqli_stmt? If so, make sure to prefix the type with \.
Loading history...
186
	 */
187 1
	public function prepare($query) {
188 1
		if (!$this->connect())
189
			return 0;
190 1
		$haltPrev = $this->haltOnError;
0 ignored issues
show
Unused Code introduced by
The assignment to $haltPrev is dead and can be removed.
Loading history...
191 1
		$this->haltOnError = 'no';
192 1
		return mysqli_prepare($this->linkId, $query);
193
	}
194
195
	/**
196
	 * Db::query()
197
	 *
198
	 *  Sends an SQL query to the database
199
	 *
200
	 * @param mixed $queryString
201
	 * @param string $line
202
	 * @param string $file
203
	 * @return mixed 0 if no query or query id handler, safe to ignore this return
204
	 */
205 5
	public function query($queryString, $line = '', $file = '') {
206
		/* No empty queries, please, since PHP4 chokes on them. */
207
		/* The empty query string is passed on from the constructor,
208
		* when calling the class without a query, e.g. in situations
209
		* like these: '$db = new db_Subclass;'
210
		*/
211 5
		if ($queryString == '')
212 1
			return 0;
213 5
		if (!$this->connect()) {
214
			return 0;
215
			/* we already complained in connect() about that. */
216
		}
217 5
		$haltPrev = $this->haltOnError;
218 5
		$this->haltOnError = 'no';
219
		// New query, discard previous result.
220 5
		if (is_resource($this->queryId))
0 ignored issues
show
introduced by
The condition is_resource($this->queryId) is always false.
Loading history...
221
			$this->free();
222 5
		if ($this->Debug)
223 5
			printf("Debug: query = %s<br>\n", $queryString);
224 5
		if (isset($GLOBALS['log_queries']) && $GLOBALS['log_queries'] !== false)
225
			$this->log($queryString, $line, $file);
226 5
		$tries = 3;
227 5
		$try = 0;
228 5
		$this->queryId = false;
229 5
		while ((null === $this->queryId || $this->queryId === false) && $try <= $tries) {
230 5
			$try++;
231 5
			if ($try > 1) {
232
				@mysqli_close($this->linkId);
0 ignored issues
show
Security Best Practice introduced by
It seems like you do not handle an error condition for mysqli_close(). This can introduce security issues, and is generally not recommended. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-unhandled  annotation

232
				/** @scrutinizer ignore-unhandled */ @mysqli_close($this->linkId);

If you suppress an error, we recommend checking for the error condition explicitly:

// For example instead of
@mkdir($dir);

// Better use
if (@mkdir($dir) === false) {
    throw new \RuntimeException('The directory '.$dir.' could not be created.');
}
Loading history...
233
				$this->connect();
234
			}
235 5
			$this->queryId = @mysqli_query($this->linkId, $queryString, MYSQLI_STORE_RESULT);
236 5
			$this->Row = 0;
237 5
			$this->Errno = @mysqli_errno($this->linkId);
238 5
			$this->Error = @mysqli_error($this->linkId);
239 5
			if ($try == 1 && (null === $this->queryId || $this->queryId === false)) {
240
				$this->emailError($queryString, 'Error #'.$this->Errno.': '.$this->Error, $line, $file);
241
			}
242
		}
243 5
		$this->haltOnError = $haltPrev;
244 5
		if (null === $this->queryId || $this->queryId === false)
245
			$this->halt('', $line, $file);
246
247
		// Will return nada if it fails. That's fine.
248 5
		return $this->queryId;
249
	}
250
251
	/**
252
	 * @return array|null|object
253
	 */
254 1
	public function fetchObject() {
255 1
		$this->Record = @mysqli_fetch_object($this->queryId);
0 ignored issues
show
Bug introduced by
$this->queryId of type integer is incompatible with the type mysqli_result expected by parameter $result of mysqli_fetch_object(). ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

255
		$this->Record = @mysqli_fetch_object(/** @scrutinizer ignore-type */ $this->queryId);
Loading history...
256 1
		return $this->Record;
257
	}
258
259
	/* public: walk result set */
260
261
	/**
262
	 * Db::next_record()
263
	 *
264
	 * @param mixed $resultType
265
	 * @return bool
266
	 */
267 4
	public function next_record($resultType = MYSQLI_BOTH) {
268 4
		if ($this->queryId === false) {
0 ignored issues
show
introduced by
The condition $this->queryId === false is always false.
Loading history...
269
			$this->halt('next_record called with no query pending.');
270
			return 0;
271
		}
272
273 4
		$this->Record = @mysqli_fetch_array($this->queryId, $resultType);
0 ignored issues
show
Bug introduced by
$this->queryId of type integer is incompatible with the type mysqli_result expected by parameter $result of mysqli_fetch_array(). ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

273
		$this->Record = @mysqli_fetch_array(/** @scrutinizer ignore-type */ $this->queryId, $resultType);
Loading history...
274 4
		++$this->Row;
275 4
		$this->Errno = mysqli_errno($this->linkId);
0 ignored issues
show
Bug introduced by
$this->linkId of type integer is incompatible with the type mysqli expected by parameter $link of mysqli_errno(). ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

275
		$this->Errno = mysqli_errno(/** @scrutinizer ignore-type */ $this->linkId);
Loading history...
276 4
		$this->Error = mysqli_error($this->linkId);
0 ignored issues
show
Bug introduced by
$this->linkId of type integer is incompatible with the type mysqli expected by parameter $link of mysqli_error(). ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

276
		$this->Error = mysqli_error(/** @scrutinizer ignore-type */ $this->linkId);
Loading history...
277
278 4
		$stat = is_array($this->Record);
279 4
		if (!$stat && $this->autoFree && is_resource($this->queryId))
0 ignored issues
show
introduced by
The condition is_resource($this->queryId) is always false.
Loading history...
280
			$this->free();
281 4
		return $stat;
282
	}
283
284
	/* public: position in result set */
285
286
	/**
287
	 * Db::seek()
288
	 * @param integer $pos
289
	 * @return int
290
	 */
291
	public function seek($pos = 0) {
292
		$status = @mysqli_data_seek($this->queryId, $pos);
0 ignored issues
show
Bug introduced by
$this->queryId of type integer is incompatible with the type mysqli_result expected by parameter $result of mysqli_data_seek(). ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

292
		$status = @mysqli_data_seek(/** @scrutinizer ignore-type */ $this->queryId, $pos);
Loading history...
293
		if ($status) {
294
			$this->Row = $pos;
295
		} else {
296
			$this->halt("seek($pos) failed: result has ".$this->num_rows().' rows');
297
			/* half assed attempt to save the day,
298
			* but do not consider this documented or even
299
			* desirable behaviour.
300
			*/
301
			@mysqli_data_seek($this->queryId, $this->num_rows());
0 ignored issues
show
Security Best Practice introduced by
It seems like you do not handle an error condition for mysqli_data_seek(). This can introduce security issues, and is generally not recommended. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-unhandled  annotation

301
			/** @scrutinizer ignore-unhandled */ @mysqli_data_seek($this->queryId, $this->num_rows());

If you suppress an error, we recommend checking for the error condition explicitly:

// For example instead of
@mkdir($dir);

// Better use
if (@mkdir($dir) === false) {
    throw new \RuntimeException('The directory '.$dir.' could not be created.');
}
Loading history...
302
			$this->Row = $this->num_rows;
0 ignored issues
show
Bug Best Practice introduced by
The property num_rows does not exist on MyDb\Mysqli\Db. Did you maybe forget to declare it?
Loading history...
303
			return 0;
304
		}
305
		return 1;
306
	}
307
308
	/**
309
	 * Initiates a transaction
310
	 *
311
	 * @return bool
312
	 */
313 14
	public function transactionBegin() {
314 14
		if (version_compare(PHP_VERSION, '5.5.0') < 0)
315
			return true;
316 14
		if (!$this->connect())
317
			return 0;
318 14
		return mysqli_begin_transaction($this->linkId);
319
	}
320
321
	/**
322
	 * Commits a transaction
323
	 *
324
	 * @return bool
325
	 */
326
	public function transactionCommit() {
327
		if (version_compare(PHP_VERSION, '5.5.0') < 0 || $this->linkId === 0)
328
			return true;
329
		return mysqli_commit($this->linkId);
0 ignored issues
show
Bug introduced by
$this->linkId of type integer is incompatible with the type mysqli expected by parameter $link of mysqli_commit(). ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

329
		return mysqli_commit(/** @scrutinizer ignore-type */ $this->linkId);
Loading history...
330
	}
331
332
	/**
333
	 * Rolls back a transaction
334
	 *
335
	 * @return bool
336
	 */
337 14
	public function transactionAbort() {
338 14
		if (version_compare(PHP_VERSION, '5.5.0') < 0 || $this->linkId === 0)
339
			return true;
340 14
		return mysqli_rollback($this->linkId);
0 ignored issues
show
Bug introduced by
$this->linkId of type integer is incompatible with the type mysqli expected by parameter $link of mysqli_rollback(). ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

340
		return mysqli_rollback(/** @scrutinizer ignore-type */ $this->linkId);
Loading history...
341
	}
342
343
	/**
344
	 * This will get the last insert ID created on the current connection.  Should only be called after an insert query is
345
	 * run on a table that has an auto incrementing field.  $table and $field are required, but unused here since it's
346
	 * unnecessary for mysql.  For compatibility with pgsql, the params must be supplied.
347
	 *
348
	 * @param string $table
349
	 * @param string $field
350
	 * @return int|string
351
	 */
352
	public function getLastInsertId($table, $field) {
353
		if (!isset($table) || $table == '' || !isset($field) || $field == '')
354
			return -1;
355
356
		return @mysqli_insert_id($this->linkId);
0 ignored issues
show
Bug introduced by
$this->linkId of type integer is incompatible with the type mysqli expected by parameter $link of mysqli_insert_id(). ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

356
		return @mysqli_insert_id(/** @scrutinizer ignore-type */ $this->linkId);
Loading history...
357
	}
358
359
	/* public: table locking */
360
361
	/**
362
	 * Db::lock()
363
	 * @param mixed  $table
364
	 * @param string $mode
365
	 * @return bool|int|\mysqli_result
366
	 */
367 1
	public function lock($table, $mode = 'write') {
368 1
		$this->connect();
369
370 1
		$query = 'lock tables ';
371 1
		if (is_array($table)) {
372 1
			while (list($key, $value) = each($table)) {
0 ignored issues
show
Deprecated Code introduced by
The function each() has been deprecated: 7.2 ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-deprecated  annotation

372
			while (list($key, $value) = /** @scrutinizer ignore-deprecated */ each($table)) {

This function has been deprecated. The supplier of the function has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the function will be removed and what other function to use instead.

Loading history...
373 1
				if ($key == 'read' && $key != 0) {
374
					$query .= "$value read, ";
375
				} else {
376 1
					$query .= "$value $mode, ";
377
				}
378
			}
379 1
			$query = mb_substr($query, 0, -2);
380
		} else {
381 1
			$query .= "$table $mode";
382
		}
383 1
		$res = @mysqli_query($this->linkId, $query);
0 ignored issues
show
Bug introduced by
$this->linkId of type integer is incompatible with the type mysqli expected by parameter $link of mysqli_query(). ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

383
		$res = @mysqli_query(/** @scrutinizer ignore-type */ $this->linkId, $query);
Loading history...
384 1
		if (!$res) {
385
			$this->halt("lock($table, $mode) failed.");
386
			return 0;
387
		}
388 1
		return $res;
389
	}
390
391
	/**
392
	 * Db::unlock()
393
	 * @param bool $haltOnError optional, defaults to TRUE, whether or not to halt on error
394
	 * @return bool|int|\mysqli_result
395
	 */
396 1
	public function unlock($haltOnError = true) {
397 1
		$this->connect();
398
399 1
		$res = @mysqli_query($this->linkId, 'unlock tables');
0 ignored issues
show
Bug introduced by
$this->linkId of type integer is incompatible with the type mysqli expected by parameter $link of mysqli_query(). ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

399
		$res = @mysqli_query(/** @scrutinizer ignore-type */ $this->linkId, 'unlock tables');
Loading history...
400 1
		if ($haltOnError === true && !$res) {
401
			$this->halt('unlock() failed.');
402
			return 0;
403
		}
404 1
		return $res;
405
	}
406
407
	/* public: evaluate the result (size, width) */
408
409
	/**
410
	 * Db::affectedRows()
411
	 * @return int
412
	 */
413
	public function affectedRows() {
414
		return @mysqli_affected_rows($this->linkId);
0 ignored issues
show
Bug introduced by
$this->linkId of type integer is incompatible with the type mysqli expected by parameter $link of mysqli_affected_rows(). ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

414
		return @mysqli_affected_rows(/** @scrutinizer ignore-type */ $this->linkId);
Loading history...
415
	}
416
417
	/**
418
	 * Db::num_rows()
419
	 * @return int
420
	 */
421 2
	public function num_rows() {
422 2
		return @mysqli_num_rows($this->queryId);
0 ignored issues
show
Bug introduced by
$this->queryId of type integer is incompatible with the type mysqli_result expected by parameter $result of mysqli_num_rows(). ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

422
		return @mysqli_num_rows(/** @scrutinizer ignore-type */ $this->queryId);
Loading history...
423
	}
424
425
	/**
426
	 * Db::num_fields()
427
	 * @return int
428
	 */
429 1
	public function num_fields() {
430 1
		return @mysqli_num_fields($this->queryId);
0 ignored issues
show
Bug introduced by
$this->queryId of type integer is incompatible with the type mysqli_result expected by parameter $result of mysqli_num_fields(). ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

430
		return @mysqli_num_fields(/** @scrutinizer ignore-type */ $this->queryId);
Loading history...
431
	}
432
433
	/**
434
	 * gets an array of the table names in teh current datase
435
	 *
436
	 * @return array
437
	 */
438 1
	public function tableNames() {
439 1
		$return = [];
440 1
		$this->query('SHOW TABLES');
441 1
		$i = 0;
442 1
		while ($info = $this->queryId->fetch_row()) {
0 ignored issues
show
Bug introduced by
The method fetch_row() does not exist on integer. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

442
		while ($info = $this->queryId->/** @scrutinizer ignore-call */ fetch_row()) {

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
443 1
			$return[$i]['table_name'] = $info[0];
444 1
			$return[$i]['tablespace_name'] = $this->database;
445 1
			$return[$i]['database'] = $this->database;
446 1
			++$i;
447
		}
448 1
		return $return;
449
	}
450
}
451
452
/**
453
 * @param $result
454
 * @param $row
455
 * @param int|string $field
456
 * @return bool
457
 */
458
/*
459
function mysqli_result($result, $row, $field = 0) {
460
	if ($result === false) return false;
461
	if ($row >= mysqli_num_rows($result)) return false;
462
	if (is_string($field) && !(mb_strpos($field, '.') === false)) {
463
		$tField = explode('.', $field);
464
		$field = -1;
465
		$tFields = mysqli_fetch_fields($result);
466
		for ($id = 0, $idMax = mysqli_num_fields($result); $id < $idMax; $id++) {
467
			if ($tFields[$id]->table == $tField[0] && $tFields[$id]->name == $tField[1]) {
468
				$field = $id;
469
				break;
470
			}
471
		}
472
		if ($field == -1) return false;
473
	}
474
	mysqli_data_seek($result, $row);
475
	$line = mysqli_fetch_array($result);
476
	return isset($line[$field]) ? $line[$field] : false;
477
}
478
*/