Test Failed
Push — master ( c97961...600310 )
by Joe
02:40
created

Db   F

Complexity

Total Complexity 78

Size/Duplication

Total Lines 405
Duplicated Lines 0 %

Test Coverage

Coverage 78.18%

Importance

Changes 0
Metric Value
eloc 154
dl 0
loc 405
ccs 129
cts 165
cp 0.7818
rs 2.16
c 0
b 0
f 0
wmc 78

23 Methods

Rating   Name   Duplication   Size   Complexity  
A useDb() 0 2 1
A selectDb() 0 3 1
B connect() 0 29 9
A real_escape() 0 4 4
A disconnect() 0 4 2
A transactionCommit() 0 4 3
A getLastInsertId() 0 5 5
A seek() 0 15 2
A fetchObject() 0 3 1
A unlock() 0 9 3
A prepare() 0 6 2
A lock() 0 21 6
A free() 0 4 2
A queryReturn() 0 12 4
A next_record() 0 15 5
C query() 0 44 16
A transactionAbort() 0 4 3
A num_rows() 0 2 1
A affectedRows() 0 2 1
A transactionBegin() 0 6 3
A tableNames() 0 11 2
A num_fields() 0 2 1
A qr() 0 2 1

How to fix   Complexity   

Complex Class

Complex classes like Db often do a lot of different things. To break such a class down, we need to identify a cohesive component within that class. A common approach to find such a component is to look for fields/methods that share the same prefixes, or suffixes.

Once you have determined the fields that belong together, you can apply the Extract Class refactoring. If the component makes sense as a sub-class, Extract Subclass is also a candidate, and is often faster.

While breaking up the class, it is a good idea to analyze how other classes use Db, and based on these observations, apply Extract Interface, too.

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
It seems like $this->linkId can also be of type integer; however, parameter $link of mysqli_select_db() does only seem to accept mysqli, maybe add an additional type check? ( 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 17
	public function connect($database = '', $host = '', $user = '', $password = '') {
58
		/* Handle defaults */
59 17
		if ($database == '')
60 17
			$database = $this->database;
61 17
		if ($host == '')
62 17
			$host = $this->host;
63 17
		if ($user == '')
64 17
			$user = $this->user;
65 17
		if ($password == '')
66 17
			$password = $this->password;
67
		/* establish connection, select database */
68 17
		if (!is_object($this->linkId)) {
69 17
			$this->connectionAttempt++;
70 17
			if ($this->connectionAttempt > 1)
71 4
				error_log("MySQLi Connection Attempt #{$this->connectionAttempt}/{$this->maxConnectErrors}");
72 17
			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 17
			$this->linkId = mysqli_init();
77 17
			$this->linkId->options(MYSQLI_INIT_COMMAND, "SET NAMES {$this->characterSet} COLLATE {$this->collation}, COLLATION_CONNECTION = {$this->collation}, COLLATION_DATABASE = {$this->collation}");
78 17
			$this->linkId->real_connect($host, $user, $password, $database);
79 17
			$this->linkId->set_charset($this->characterSet);
80 17
			if ($this->linkId->connect_errno) {
81
				$this->halt("connect($host, $user, \$password) failed. ".$mysqli->connect_error);
82
				return 0;
83
			}
84
		}
85 17
		return $this->linkId;
86
	}
87
88
	/**
89
	 * Db::disconnect()
90
	 * @return bool
91
	 */
92 1
	public function disconnect() {
93 1
		$return = method_exists($this->linkId, 'close') ? $this->linkId->close() : false;
94 1
		$this->linkId = 0;
95 1
		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
	 * discard the query result
110
	 * @return void
111
	 */
112 1
	public function free() {
113
		if (is_resource($this->queryId))
0 ignored issues
show
introduced by
The condition is_resource($this->queryId) is always false.
Loading history...
114
			@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

114
			/** @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...
115 1
		$this->queryId = 0;
116
	}
117
118
	/**
119
	 * Db::queryReturn()
120
	 *
121
	 * Sends an SQL query to the server like the normal query() command but iterates through
122
	 * any rows and returns the row or rows immediately or FALSE on error
123 1
	 *
124 1
	 * @param mixed $query SQL Query to be used
125 1
	 * @param string $line optionally pass __LINE__ calling the query for logging
126 1
	 * @param string $file optionally pass __FILE__ calling the query for logging
127
	 * @return mixed FALSE if no rows, if a single row it returns that, if multiple it returns an array of rows, associative responses only
128
	 */
129
	public function queryReturn($query, $line = '', $file = '') {
130
		$this->query($query, $line, $file);
131
		if ($this->num_rows() == 0) {
132
			return false;
133
		} elseif ($this->num_rows() == 1) {
134
			$this->next_record(MYSQLI_ASSOC);
135 1
			return $this->Record;
136 1
		} else {
137
			$out = [];
138 1
			while ($this->next_record(MYSQLI_ASSOC))
139
				$out[] = $this->Record;
140
			return $out;
141
		}
142
	}
143
144
	/**
145
	 * db:qr()
146
	 *
147
	 *  alias of queryReturn()
148
	 *
149
	 * @param mixed $query SQL Query to be used
150
	 * @param string $line optionally pass __LINE__ calling the query for logging
151
	 * @param string $file optionally pass __FILE__ calling the query for logging
152 1
	 * @return mixed FALSE if no rows, if a single row it returns that, if multiple it returns an array of rows, associative responses only
153 1
	 */
154 1
	public function qr($query, $line = '', $file = '') {
155 1
		return $this->queryReturn($query, $line, $file);
156 1
	}
157 1
158 1
	/**
159
	 * creates a prepaired statement from query
160 1
	 *
161 1
	 * @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 = ?
162 1
	 * @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...
163 1
	 */
164
	public function prepare($query) {
165
		if (!$this->connect())
166
			return 0;
167
		$haltPrev = $this->haltOnError;
0 ignored issues
show
Unused Code introduced by
The assignment to $haltPrev is dead and can be removed.
Loading history...
168
		$this->haltOnError = 'no';
169
		return mysqli_prepare($this->linkId, $query);
170
	}
171
172
	/**
173
	 * Db::query()
174
	 *
175
	 *  Sends an SQL query to the database
176
	 *
177 1
	 * @param mixed $queryString
178 1
	 * @param string $line
179
	 * @param string $file
180
	 * @return mixed 0 if no query or query id handler, safe to ignore this return
181
	 */
182
	public function query($queryString, $line = '', $file = '') {
183
		/* No empty queries, please, since PHP4 chokes on them. */
184
		/* The empty query string is passed on from the constructor,
185
		* when calling the class without a query, e.g. in situations
186
		* like these: '$db = new db_Subclass;'
187 1
		*/
188 1
		if ($queryString == '')
189
			return 0;
190 1
		if (!$this->connect()) {
191 1
			return 0;
192 1
			/* we already complained in connect() about that. */
193
		}
194
		$haltPrev = $this->haltOnError;
195
		$this->haltOnError = 'no';
196
		// New query, discard previous result.
197
		if (is_resource($this->queryId))
0 ignored issues
show
introduced by
The condition is_resource($this->queryId) is always false.
Loading history...
198
			$this->free();
199
		if ($this->Debug)
200
			printf("Debug: query = %s<br>\n", $queryString);
201
		if (isset($GLOBALS['log_queries']) && $GLOBALS['log_queries'] !== false)
202
			$this->log($queryString, $line, $file);
203
		$tries = 3;
204
		$try = 0;
205 7
		$this->queryId = false;
206
		while ((null === $this->queryId || $this->queryId === false) && $try <= $tries) {
207
			$try++;
208
			if ($try > 1) {
209
				@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

209
				/** @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...
210
				$this->connect();
211 7
			}
212 1
			$this->queryId = @mysqli_query($this->linkId, $queryString, MYSQLI_STORE_RESULT);
213 7
			$this->Row = 0;
214
			$this->Errno = @mysqli_errno($this->linkId);
215
			$this->Error = @mysqli_error($this->linkId);
216
			if ($try == 1 && (null === $this->queryId || $this->queryId === false)) {
217 7
				$this->emailError($queryString, 'Error #'.$this->Errno.': '.$this->Error, $line, $file);
218 7
			}
219
		}
220 7
		$this->haltOnError = $haltPrev;
221
		if (null === $this->queryId || $this->queryId === false)
222 7
			$this->halt('', $line, $file);
223 7
224 7
		// Will return nada if it fails. That's fine.
225
		return $this->queryId;
226 7
	}
227 7
228 7
	/**
229 7
	 * @return array|null|object
230 7
	 */
231 7
	public function fetchObject() {
232
		$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

232
		$this->Record = @mysqli_fetch_object(/** @scrutinizer ignore-type */ $this->queryId);
Loading history...
233
		return $this->Record;
234
	}
235 7
236 7
	/* public: walk result set */
237 7
238 7
	/**
239 7
	 * Db::next_record()
240
	 *
241
	 * @param mixed $resultType
242
	 * @return bool
243 7
	 */
244 7
	public function next_record($resultType = MYSQLI_BOTH) {
245
		if ($this->queryId === false) {
0 ignored issues
show
introduced by
The condition $this->queryId === false is always false.
Loading history...
246
			$this->halt('next_record called with no query pending.');
247
			return 0;
248 7
		}
249
250
		$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

250
		$this->Record = @mysqli_fetch_array(/** @scrutinizer ignore-type */ $this->queryId, $resultType);
Loading history...
251
		++$this->Row;
252
		$this->Errno = mysqli_errno($this->linkId);
0 ignored issues
show
Bug introduced by
It seems like $this->linkId can also be of type integer; however, parameter $link of mysqli_errno() does only seem to accept mysqli, maybe add an additional type check? ( Ignorable by Annotation )

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

252
		$this->Errno = mysqli_errno(/** @scrutinizer ignore-type */ $this->linkId);
Loading history...
253
		$this->Error = mysqli_error($this->linkId);
0 ignored issues
show
Bug introduced by
It seems like $this->linkId can also be of type integer; however, parameter $link of mysqli_error() does only seem to accept mysqli, maybe add an additional type check? ( Ignorable by Annotation )

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

253
		$this->Error = mysqli_error(/** @scrutinizer ignore-type */ $this->linkId);
Loading history...
254 1
255 1
		$stat = is_array($this->Record);
256 1
		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...
257
			$this->free();
258
		return $stat;
259
	}
260
261
	/* public: position in result set */
262
263
	/**
264
	 * Db::seek()
265
	 * @param integer $pos
266
	 * @return int
267 4
	 */
268 4
	public function seek($pos = 0) {
269
		$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

269
		$status = @mysqli_data_seek(/** @scrutinizer ignore-type */ $this->queryId, $pos);
Loading history...
270
		if ($status) {
271
			$this->Row = $pos;
272
		} else {
273 4
			$this->halt("seek($pos) failed: result has ".$this->num_rows().' rows');
274 4
			/* half assed attempt to save the day,
275 4
			* but do not consider this documented or even
276 4
			* desirable behaviour.
277
			*/
278 4
			@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

278
			/** @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...
279 4
			$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...
280
			return 0;
281 4
		}
282
		return 1;
283
	}
284
285
	/**
286
	 * Initiates a transaction
287
	 *
288
	 * @return bool
289
	 */
290
	public function transactionBegin() {
291
		if (version_compare(PHP_VERSION, '5.5.0') < 0)
292
			return true;
293
		if (!$this->connect())
294
			return 0;
295
		return mysqli_begin_transaction($this->linkId);
296
	}
297
298
	/**
299
	 * Commits a transaction
300
	 *
301
	 * @return bool
302
	 */
303
	public function transactionCommit() {
304
		if (version_compare(PHP_VERSION, '5.5.0') < 0 || $this->linkId === 0)
305
			return true;
306
		return mysqli_commit($this->linkId);
0 ignored issues
show
Bug introduced by
It seems like $this->linkId can also be of type integer; however, parameter $link of mysqli_commit() does only seem to accept mysqli, maybe add an additional type check? ( Ignorable by Annotation )

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

306
		return mysqli_commit(/** @scrutinizer ignore-type */ $this->linkId);
Loading history...
307
	}
308
309
	/**
310
	 * Rolls back a transaction
311
	 *
312
	 * @return bool
313 17
	 */
314 17
	public function transactionAbort() {
315
		if (version_compare(PHP_VERSION, '5.5.0') < 0 || $this->linkId === 0)
316 17
			return true;
317
		return mysqli_rollback($this->linkId);
0 ignored issues
show
Bug introduced by
It seems like $this->linkId can also be of type integer; however, parameter $link of mysqli_rollback() does only seem to accept mysqli, maybe add an additional type check? ( Ignorable by Annotation )

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

317
		return mysqli_rollback(/** @scrutinizer ignore-type */ $this->linkId);
Loading history...
318 17
	}
319
320
	/**
321
	 * This will get the last insert ID created on the current connection.  Should only be called after an insert query is
322
	 * run on a table that has an auto incrementing field.  $table and $field are required, but unused here since it's
323
	 * unnecessary for mysql.  For compatibility with pgsql, the params must be supplied.
324
	 *
325
	 * @param string $table
326 1
	 * @param string $field
327 1
	 * @return int|string
328
	 */
329 1
	public function getLastInsertId($table, $field) {
330
		if (!isset($table) || $table == '' || !isset($field) || $field == '')
331
			return -1;
332
333
		return @mysqli_insert_id($this->linkId);
0 ignored issues
show
Bug introduced by
It seems like $this->linkId can also be of type integer; however, parameter $link of mysqli_insert_id() does only seem to accept mysqli, maybe add an additional type check? ( Ignorable by Annotation )

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

333
		return @mysqli_insert_id(/** @scrutinizer ignore-type */ $this->linkId);
Loading history...
334
	}
335
336
	/* public: table locking */
337 17
338 17
	/**
339
	 * Db::lock()
340 17
	 * @param mixed  $table
341
	 * @param string $mode
342
	 * @return bool|int|\mysqli_result
343
	 */
344
	public function lock($table, $mode = 'write') {
345
		$this->connect();
346
		$query = 'lock tables ';
347
		if (is_array($table)) {
348
			foreach ($table as $key => $value) {
349
				if ($key == 'read' && $key != 0) {
350
					$query .= "$value read, ";
351
				} else {
352 1
					$query .= "$value $mode, ";
353 1
				}
354
			}
355
			$query = mb_substr($query, 0, -2);
356 1
		} else {
357
			$query .= "$table $mode";
358
		}
359
		$res = @mysqli_query($this->linkId, $query);
0 ignored issues
show
Bug introduced by
It seems like $this->linkId can also be of type integer; however, parameter $link of mysqli_query() does only seem to accept mysqli, maybe add an additional type check? ( Ignorable by Annotation )

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

359
		$res = @mysqli_query(/** @scrutinizer ignore-type */ $this->linkId, $query);
Loading history...
360
		if (!$res) {
361
			$this->halt("lock($table, $mode) failed.");
362
			return 0;
363
		}
364
		return $res;
365
	}
366
367 1
	/**
368 1
	 * Db::unlock()
369 1
	 * @param bool $haltOnError optional, defaults to TRUE, whether or not to halt on error
370 1
	 * @return bool|int|\mysqli_result
371 1
	 */
372 1
	public function unlock($haltOnError = true) {
373
		$this->connect();
374
375 1
		$res = @mysqli_query($this->linkId, 'unlock tables');
0 ignored issues
show
Bug introduced by
It seems like $this->linkId can also be of type integer; however, parameter $link of mysqli_query() does only seem to accept mysqli, maybe add an additional type check? ( Ignorable by Annotation )

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

375
		$res = @mysqli_query(/** @scrutinizer ignore-type */ $this->linkId, 'unlock tables');
Loading history...
376
		if ($haltOnError === true && !$res) {
377
			$this->halt('unlock() failed.');
378 1
			return 0;
379
		}
380 1
		return $res;
381
	}
382 1
383 1
	/* public: evaluate the result (size, width) */
384
385
	/**
386
	 * Db::affectedRows()
387 1
	 * @return int
388
	 */
389
	public function affectedRows() {
390
		return @mysqli_affected_rows($this->linkId);
0 ignored issues
show
Bug introduced by
It seems like $this->linkId can also be of type integer; however, parameter $link of mysqli_affected_rows() does only seem to accept mysqli, maybe add an additional type check? ( Ignorable by Annotation )

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

390
		return @mysqli_affected_rows(/** @scrutinizer ignore-type */ $this->linkId);
Loading history...
391
	}
392
393
	/**
394
	 * Db::num_rows()
395 1
	 * @return int
396 1
	 */
397
	public function num_rows() {
398 1
		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

398
		return @mysqli_num_rows(/** @scrutinizer ignore-type */ $this->queryId);
Loading history...
399 1
	}
400
401
	/**
402
	 * Db::num_fields()
403 1
	 * @return int
404
	 */
405
	public function num_fields() {
406
		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

406
		return @mysqli_num_fields(/** @scrutinizer ignore-type */ $this->queryId);
Loading history...
407
	}
408
409
	/**
410
	 * gets an array of the table names in teh current datase
411
	 *
412 2
	 * @return array
413 2
	 */
414
	public function tableNames() {
415
		$return = [];
416
		$this->query('SHOW TABLES');
417
		$i = 0;
418
		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

418
		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...
419
			$return[$i]['table_name'] = $info[0];
420 3
			$return[$i]['tablespace_name'] = $this->database;
421 3
			$return[$i]['database'] = $this->database;
422
			++$i;
423
		}
424
		return $return;
425
	}
426
}
427
428 1
/**
429 1
 * @param $result
430
 * @param $row
431
 * @param int|string $field
432
 * @return bool
433
 */
434
/*
435
function mysqli_result($result, $row, $field = 0) {
436
	if ($result === false) return false;
437 1
	if ($row >= mysqli_num_rows($result)) return false;
438 1
	if (is_string($field) && !(mb_strpos($field, '.') === false)) {
439 1
		$tField = explode('.', $field);
440 1
		$field = -1;
441 1
		$tFields = mysqli_fetch_fields($result);
442 1
		for ($id = 0, $idMax = mysqli_num_fields($result); $id < $idMax; $id++) {
443 1
			if ($tFields[$id]->table == $tField[0] && $tFields[$id]->name == $tField[1]) {
444 1
				$field = $id;
445 1
				break;
446
			}
447 1
		}
448
		if ($field == -1) return false;
449
	}
450
	mysqli_data_seek($result, $row);
451
	$line = mysqli_fetch_array($result);
452
	return isset($line[$field]) ? $line[$field] : false;
453
}
454
*/