Completed
Pull Request — master (#2936)
by
unknown
04:53
created

includes/dbFacile.mysqli.php (17 issues)

Upgrade to new PHP Analysis Engine

These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more

1
<?php
2
3
/*
4
 * dbFacile - A Database API that should have existed from the start
5
 * Version 0.4.3
6
 *
7
 * This code is covered by the MIT license http://en.wikipedia.org/wiki/MIT_License
8
 *
9
 * By Alan Szlosek from http://www.greaterscope.net/projects/dbFacile
10
 *
11
 * The non-OO version of dbFacile. It's a bit simplistic, but gives you the
12
 * really useful bits in non-class form.
13
 *
14
 * Usage
15
 * 1. Connect to MySQL as you normally would ... this code uses an existing connection
16
 * 2. Use dbFacile as you normally would, without the object context
17
 * 3. Oh, and dbFetchAll() is now dbFetchRows()
18
 */
19
20
/*
21
 * Performs a query using the given string.
22
 * Used by the other _query functions.
23
 * */
24
25
26 View Code Duplication
function dbQuery($sql, $parameters=array()) {
0 ignored issues
show
The function dbQuery() has been defined more than once; this definition is ignored, only the first definition in includes/dbFacile.mysql.php (L26-64) is considered.

This check looks for functions that have already been defined in other files.

Some Codebases, like WordPress, make a practice of defining functions multiple times. This may lead to problems with the detection of function parameters and types. If you really need to do this, you can mark the duplicate definition with the @ignore annotation.

/**
 * @ignore
 */
function getUser() {

}

function getUser($id, $realm) {

}

See also the PhpDoc documentation for @ignore.

Loading history...
27
    global $fullSql, $debug, $sql_debug, $console_color, $database_link;
28
    $fullSql = dbMakeQuery($sql, $parameters);
29
    if ($debug) {
30
        if (php_sapi_name() == 'cli' && empty($_SERVER['REMOTE_ADDR'])) {
31
            if (preg_match('/(INSERT INTO `alert_log`).*(details)/i',$fullSql)) {
32
                echo "\nINSERT INTO `alert_log` entry masked due to binary data\n";
33
            }
34
            else {
35
                print $console_color->convert("\nSQL[%y".$fullSql.'%n] ');
36
            }
37
        }
38
        else {
39
            $sql_debug[] = $fullSql;
40
        }
41
    }
42
43
    /*
44
        if($this->logFile)
45
        $time_start = microtime(true);
46
     */
47
48
    $result = mysqli_query($database_link, $fullSql);
49
    // sets $this->result
50
    /*
51
        if($this->logFile) {
52
        $time_end = microtime(true);
53
        fwrite($this->logFile, date('Y-m-d H:i:s') . "\n" . $fullSql . "\n" . number_format($time_end - $time_start, 8) . " seconds\n\n");
54
        }
55
     */
56
57
    if ($result === false && (error_reporting() & 1)) {
58
        // aye. this gets triggers on duplicate Contact insert
59
        // trigger_error('QDB - Error in query: ' . $fullSql . ' : ' . mysql_error(), E_USER_WARNING);
60
    }
61
62
    return $result;
63
64
}//end dbQuery()
65
66
67
/*
68
 * Passed an array and a table name, it attempts to insert the data into the table.
69
 * Check for boolean false to determine whether insert failed
70
 * */
71
72
73 View Code Duplication
function dbInsert($data, $table) {
0 ignored issues
show
The function dbInsert() has been defined more than once; this definition is ignored, only the first definition in includes/dbFacile.mysql.php (L73-113) is considered.

This check looks for functions that have already been defined in other files.

Some Codebases, like WordPress, make a practice of defining functions multiple times. This may lead to problems with the detection of function parameters and types. If you really need to do this, you can mark the duplicate definition with the @ignore annotation.

/**
 * @ignore
 */
function getUser() {

}

function getUser($id, $realm) {

}

See also the PhpDoc documentation for @ignore.

Loading history...
74
    global $fullSql, $database_link;
75
    global $db_stats;
76
    // the following block swaps the parameters if they were given in the wrong order.
77
    // it allows the method to work for those that would rather it (or expect it to)
78
    // follow closer with SQL convention:
79
    // insert into the TABLE this DATA
80
    if (is_string($data) && is_array($table)) {
81
        $tmp   = $data;
82
        $data  = $table;
83
        $table = $tmp;
84
        // trigger_error('QDB - Parameters passed to insert() were in reverse order, but it has been allowed', E_USER_NOTICE);
85
    }
86
87
    $sql = 'INSERT INTO `'.$table.'` (`'.implode('`,`', array_keys($data)).'`)  VALUES ('.implode(',', dbPlaceHolders($data)).')';
88
89
    $time_start = microtime(true);
90
    dbBeginTransaction();
91
    $result = dbQuery($sql, $data);
92
    if ($result) {
93
        $id = mysqli_insert_id($database_link);
94
        dbCommitTransaction();
95
        // return $id;
96
    }
97
    else {
98
        if ($table != 'Contact') {
99
            trigger_error('QDB - Insert failed.', E_USER_WARNING);
100
        }
101
102
        dbRollbackTransaction();
103
        // $id = false;
104
    }
105
106
    // logfile($fullSql);
107
    $time_end                = microtime(true);
108
    $db_stats['insert_sec'] += number_format(($time_end - $time_start), 8);
109
    $db_stats['insert']++;
110
111
    return $id;
112
113
}//end dbInsert()
114
115
116
/*
117
 * Passed an array and a table name, it attempts to insert the data into the table.
118
 * $data is an array (rows) of key value pairs.  keys are fields.  Rows need to have same fields.
119
 * Check for boolean false to determine whether insert failed
120
 * */
121
122
123 View Code Duplication
function dbBulkInsert($data, $table) {
0 ignored issues
show
The function dbBulkInsert() has been defined more than once; this definition is ignored, only the first definition in includes/dbFacile.mysql.php (L123-168) is considered.

This check looks for functions that have already been defined in other files.

Some Codebases, like WordPress, make a practice of defining functions multiple times. This may lead to problems with the detection of function parameters and types. If you really need to do this, you can mark the duplicate definition with the @ignore annotation.

/**
 * @ignore
 */
function getUser() {

}

function getUser($id, $realm) {

}

See also the PhpDoc documentation for @ignore.

Loading history...
124
    global $db_stats;
125
    // the following block swaps the parameters if they were given in the wrong order.
126
    // it allows the method to work for those that would rather it (or expect it to)
127
    // follow closer with SQL convention:
128
    // insert into the TABLE this DATA
129
    if (is_string($data) && is_array($table)) {
130
        $tmp   = $data;
131
        $data  = $table;
132
        $table = $tmp;
133
    }
134
    if (count($data) === 0) {
135
        return false;
136
    }
137
    if (count($data[0]) === 0) {
138
        return false;
139
    }
140
141
    $sql = 'INSERT INTO `'.$table.'` (`'.implode('`,`', array_keys($data[0])).'`)  VALUES ';
142
    $values ='';
143
144
    foreach ($data as $row) {
145
        if ($values != '') {
146
            $values .= ',';
147
        }
148
        $rowvalues='';
149
        foreach ($row as $key => $value) {
150
            if ($rowvalues != '') {
151
                $rowvalues .= ',';
152
            }
153
            $rowvalues .= "'".mres($value)."'";
154
        }
155
        $values .= "(".$rowvalues.")";
156
    }
157
158
    $time_start = microtime(true);
159
    $result = dbQuery($sql.$values);
160
161
    // logfile($fullSql);
162
    $time_end                = microtime(true);
163
    $db_stats['insert_sec'] += number_format(($time_end - $time_start), 8);
164
    $db_stats['insert']++;
165
166
    return $result;
167
168
}//end dbBulkInsert()
169
170
171
/*
172
 * Passed an array, table name, WHERE clause, and placeholder parameters, it attempts to update a record.
173
 * Returns the number of affected rows
174
 * */
175
176
177 View Code Duplication
function dbUpdate($data, $table, $where=null, $parameters=array()) {
0 ignored issues
show
The function dbUpdate() has been defined more than once; this definition is ignored, only the first definition in includes/dbFacile.mysql.php (L177-221) is considered.

This check looks for functions that have already been defined in other files.

Some Codebases, like WordPress, make a practice of defining functions multiple times. This may lead to problems with the detection of function parameters and types. If you really need to do this, you can mark the duplicate definition with the @ignore annotation.

/**
 * @ignore
 */
function getUser() {

}

function getUser($id, $realm) {

}

See also the PhpDoc documentation for @ignore.

Loading history...
178
    global $fullSql, $database_link;
179
    global $db_stats;
180
    // the following block swaps the parameters if they were given in the wrong order.
181
    // it allows the method to work for those that would rather it (or expect it to)
182
    // follow closer with SQL convention:
183
    // update the TABLE with this DATA
184
    if (is_string($data) && is_array($table)) {
185
        $tmp   = $data;
186
        $data  = $table;
187
        $table = $tmp;
188
        // trigger_error('QDB - The first two parameters passed to update() were in reverse order, but it has been allowed', E_USER_NOTICE);
189
    }
190
191
    // need field name and placeholder value
192
    // but how merge these field placeholders with actual $parameters array for the WHERE clause
193
    $sql = 'UPDATE `'.$table.'` set ';
194
    foreach ($data as $key => $value) {
195
        $sql .= '`'.$key.'` '.'=:'.$key.',';
196
    }
197
198
    $sql = substr($sql, 0, -1);
199
    // strip off last comma
200
    if ($where) {
201
        $sql .= ' WHERE '.$where;
202
        $data = array_merge($data, $parameters);
203
    }
204
205
    $time_start = microtime(true);
206
    if (dbQuery($sql, $data)) {
207
        $return = mysqli_affected_rows($database_link);
208
    }
209
    else {
210
        // echo("$fullSql");
211
        trigger_error('QDB - Update failed.', E_USER_WARNING);
212
        $return = false;
213
    }
214
215
    $time_end                = microtime(true);
216
    $db_stats['update_sec'] += number_format(($time_end - $time_start), 8);
217
    $db_stats['update']++;
218
219
    return $return;
220
221
}//end dbUpdate()
222
223
224 View Code Duplication
function dbDelete($table, $where=null, $parameters=array()) {
0 ignored issues
show
The function dbDelete() has been defined more than once; this definition is ignored, only the first definition in includes/dbFacile.mysql.php (L224-237) is considered.

This check looks for functions that have already been defined in other files.

Some Codebases, like WordPress, make a practice of defining functions multiple times. This may lead to problems with the detection of function parameters and types. If you really need to do this, you can mark the duplicate definition with the @ignore annotation.

/**
 * @ignore
 */
function getUser() {

}

function getUser($id, $realm) {

}

See also the PhpDoc documentation for @ignore.

Loading history...
225
    global $database_link;
226
    $sql = 'DELETE FROM `'.$table.'`';
227
    if ($where) {
228
        $sql .= ' WHERE '.$where;
229
    }
230
231
    if (dbQuery($sql, $parameters)) {
232
        return mysqli_affected_rows($database_link);
233
    }
234
    else {
235
        return false;
236
    }
237
238
}//end dbDelete()
239
240
241
/*
242
 * Fetches all of the rows (associatively) from the last performed query.
243
 * Most other retrieval functions build off this
244
 * */
245
246
247 View Code Duplication
function dbFetchRows($sql, $parameters=array(), $nocache=false) {
0 ignored issues
show
The function dbFetchRows() has been defined more than once; this definition is ignored, only the first definition in includes/dbFacile.mysql.php (L246-282) is considered.

This check looks for functions that have already been defined in other files.

Some Codebases, like WordPress, make a practice of defining functions multiple times. This may lead to problems with the detection of function parameters and types. If you really need to do this, you can mark the duplicate definition with the @ignore annotation.

/**
 * @ignore
 */
function getUser() {

}

function getUser($id, $realm) {

}

See also the PhpDoc documentation for @ignore.

Loading history...
248
    global $db_stats, $config;
249
250
    if ($config['memcached']['enable'] && $nocache === false) {
251
        $result = $config['memcached']['resource']->get(hash('sha512',$sql.'|'.serialize($parameters)));
252
        if (!empty($result)) {
253
            return $result;
254
        }
255
    }
256
257
    $time_start = microtime(true);
258
    $result         = dbQuery($sql, $parameters);
259
260
    if (mysqli_num_rows($result) > 0) {
261
        $rows = array();
262
        while ($row = mysqli_fetch_assoc($result)) {
263
            $rows[] = $row;
264
        }
265
266
        mysqli_free_result($result);
267
        if ($config['memcached']['enable'] && $nocache === false) {
268
            $config['memcached']['resource']->set(hash('sha512',$sql.'|'.serialize($parameters)),$rows,$config['memcached']['ttl']);
269
        }
270
        return $rows;
271
    }
272
273
    mysqli_free_result($result);
274
275
    $time_end                   = microtime(true);
276
    $db_stats['fetchrows_sec'] += number_format(($time_end - $time_start), 8);
277
    $db_stats['fetchrows']++;
278
279
    // no records, thus return empty array
280
    // which should evaluate to false, and will prevent foreach notices/warnings
281
    return array();
282
283
}//end dbFetchRows()
284
285
286
/*
287
 * This is intended to be the method used for large result sets.
288
 * It is intended to return an iterator, and act upon buffered data.
289
 * */
290
291
292
function dbFetch($sql, $parameters=array(), $nocache=false) {
0 ignored issues
show
The function dbFetch() has been defined more than once; this definition is ignored, only the first definition in includes/dbFacile.mysql.php (L291-304) is considered.

This check looks for functions that have already been defined in other files.

Some Codebases, like WordPress, make a practice of defining functions multiple times. This may lead to problems with the detection of function parameters and types. If you really need to do this, you can mark the duplicate definition with the @ignore annotation.

/**
 * @ignore
 */
function getUser() {

}

function getUser($id, $realm) {

}

See also the PhpDoc documentation for @ignore.

Loading history...
293
    return dbFetchRows($sql, $parameters, $nocache);
294
    /*
295
        // for now, don't do the iterator thing
296
        $result = dbQuery($sql, $parameters);
297
        if($result) {
298
        // return new iterator
299
        return new dbIterator($result);
300
        } else {
301
        return null; // ??
302
        }
303
     */
304
305
}//end dbFetch()
306
307
308
/*
309
 * Like fetch(), accepts any number of arguments
310
 * The first argument is an sprintf-ready query stringTypes
311
 * */
312
313
314 View Code Duplication
function dbFetchRow($sql=null, $parameters=array(), $nocache=false) {
0 ignored issues
show
The function dbFetchRow() has been defined more than once; this definition is ignored, only the first definition in includes/dbFacile.mysql.php (L313-344) is considered.

This check looks for functions that have already been defined in other files.

Some Codebases, like WordPress, make a practice of defining functions multiple times. This may lead to problems with the detection of function parameters and types. If you really need to do this, you can mark the duplicate definition with the @ignore annotation.

/**
 * @ignore
 */
function getUser() {

}

function getUser($id, $realm) {

}

See also the PhpDoc documentation for @ignore.

Loading history...
315
    global $db_stats, $config;
316
317
    if ($config['memcached']['enable'] && $nocache === false) {
318
        $result = $config['memcached']['resource']->get(hash('sha512',$sql.'|'.serialize($parameters)));
319
        if (!empty($result)) {
320
            return $result;
321
        }
322
    }
323
324
    $time_start = microtime(true);
325
    $result         = dbQuery($sql, $parameters);
326
    if ($result) {
327
        $row = mysqli_fetch_assoc($result);
328
        mysqli_free_result($result);
329
        $time_end = microtime(true);
330
331
        $db_stats['fetchrow_sec'] += number_format(($time_end - $time_start), 8);
332
        $db_stats['fetchrow']++;
333
334
        if ($config['memcached']['enable'] && $nocache === false) {
335
            $config['memcached']['resource']->set(hash('sha512',$sql.'|'.serialize($parameters)),$row,$config['memcached']['ttl']);
336
        }
337
        return $row;
338
    }
339
    else {
340
        return null;
341
    }
342
343
    $time_start = microtime(true);
344
345
}//end dbFetchRow()
346
347
348
/*
349
 * Fetches the first call from the first row returned by the query
350
 * */
351
352
353 View Code Duplication
function dbFetchCell($sql, $parameters=array(), $nocache=false) {
0 ignored issues
show
The function dbFetchCell() has been defined more than once; this definition is ignored, only the first definition in includes/dbFacile.mysql.php (L352-368) is considered.

This check looks for functions that have already been defined in other files.

Some Codebases, like WordPress, make a practice of defining functions multiple times. This may lead to problems with the detection of function parameters and types. If you really need to do this, you can mark the duplicate definition with the @ignore annotation.

/**
 * @ignore
 */
function getUser() {

}

function getUser($id, $realm) {

}

See also the PhpDoc documentation for @ignore.

Loading history...
354
    global $db_stats, $config;
355
356
    $time_start = microtime(true);
357
    $row            = dbFetchRow($sql, $parameters, $nocache);
358
    if ($row) {
359
        return array_shift($row);
360
        // shift first field off first row
361
    }
362
363
    $time_end = microtime(true);
364
365
    $db_stats['fetchcell_sec'] += number_format(($time_end - $time_start), 8);
366
    $db_stats['fetchcell']++;
367
368
    return null;
369
370
}//end dbFetchCell()
371
372
373
/*
374
 * This method is quite different from fetchCell(), actually
375
 * It fetches one cell from each row and places all the values in 1 array
376
 * */
377
378
379 View Code Duplication
function dbFetchColumn($sql, $parameters=array(), $nocache=false) {
0 ignored issues
show
The function dbFetchColumn() has been defined more than once; this definition is ignored, only the first definition in includes/dbFacile.mysql.php (L377-392) is considered.

This check looks for functions that have already been defined in other files.

Some Codebases, like WordPress, make a practice of defining functions multiple times. This may lead to problems with the detection of function parameters and types. If you really need to do this, you can mark the duplicate definition with the @ignore annotation.

/**
 * @ignore
 */
function getUser() {

}

function getUser($id, $realm) {

}

See also the PhpDoc documentation for @ignore.

Loading history...
380
    global $db_stats;
381
    $time_start = microtime(true);
382
    $cells          = array();
383
    foreach (dbFetch($sql, $parameters, $nocache) as $row) {
384
        $cells[] = array_shift($row);
385
    }
386
387
    $time_end = microtime(true);
388
389
    $db_stats['fetchcol_sec'] += number_format(($time_end - $time_start), 8);
390
    $db_stats['fetchcol']++;
391
392
    return $cells;
393
394
}//end dbFetchColumn()
395
396
397
/*
398
 * Should be passed a query that fetches two fields
399
 * The first will become the array key
400
 * The second the key's value
401
 */
402
403
404 View Code Duplication
function dbFetchKeyValue($sql, $parameters=array(), $nocache=false) {
0 ignored issues
show
The function dbFetchKeyValue() has been defined more than once; this definition is ignored, only the first definition in includes/dbFacile.mysql.php (L402-420) is considered.

This check looks for functions that have already been defined in other files.

Some Codebases, like WordPress, make a practice of defining functions multiple times. This may lead to problems with the detection of function parameters and types. If you really need to do this, you can mark the duplicate definition with the @ignore annotation.

/**
 * @ignore
 */
function getUser() {

}

function getUser($id, $realm) {

}

See also the PhpDoc documentation for @ignore.

Loading history...
405
    $data = array();
406
    foreach (dbFetch($sql, $parameters, $nocache) as $row) {
407
        $key = array_shift($row);
408
        if (sizeof($row) == 1) {
409
            // if there were only 2 fields in the result
410
            // use the second for the value
411
            $data[$key] = array_shift($row);
412
        }
413
        else {
414
            // if more than 2 fields were fetched
415
            // use the array of the rest as the value
416
            $data[$key] = $row;
417
        }
418
    }
419
420
    return $data;
421
422
}//end dbFetchKeyValue()
423
424
425
/*
426
 * This combines a query and parameter array into a final query string for execution
427
 * PDO drivers don't need to use this
428
 */
429
430
431 View Code Duplication
function dbMakeQuery($sql, $parameters) {
0 ignored issues
show
The function dbMakeQuery() has been defined more than once; this definition is ignored, only the first definition in includes/dbFacile.mysql.php (L429-474) is considered.

This check looks for functions that have already been defined in other files.

Some Codebases, like WordPress, make a practice of defining functions multiple times. This may lead to problems with the detection of function parameters and types. If you really need to do this, you can mark the duplicate definition with the @ignore annotation.

/**
 * @ignore
 */
function getUser() {

}

function getUser($id, $realm) {

}

See also the PhpDoc documentation for @ignore.

Loading history...
432
    // bypass extra logic if we have no parameters
433
    if (sizeof($parameters) == 0) {
434
        return $sql;
435
    }
436
437
    $parameters = dbPrepareData($parameters);
438
    // separate the two types of parameters for easier handling
439
    $questionParams = array();
440
    $namedParams    = array();
441
    foreach ($parameters as $key => $value) {
442
        if (is_numeric($key)) {
443
            $questionParams[] = $value;
444
        }
445
        else {
446
            $namedParams[':'.$key] = $value;
447
        }
448
    }
449
450
    // sort namedParams in reverse to stop substring squashing
451
    krsort($namedParams);
452
453
    // split on question-mark and named placeholders
454
    $result = preg_split('/(\?|:[a-zA-Z0-9_-]+)/', $sql, -1, (PREG_SPLIT_NO_EMPTY | PREG_SPLIT_DELIM_CAPTURE));
455
456
    // every-other item in $result will be the placeholder that was found
457
    $query            = '';
458
    $res_size = sizeof($result);
459
    for ($i = 0; $i < $res_size; $i += 2) {
460
        $query .= $result[$i];
461
462
        $j = ($i + 1);
463
        if (array_key_exists($j, $result)) {
464
            $test = $result[$j];
465
            if ($test == '?') {
466
                $query .= array_shift($questionParams);
467
            }
468
            else {
469
                $query .= $namedParams[$test];
470
            }
471
        }
472
    }
473
474
    return $query;
475
476
}//end dbMakeQuery()
477
478
479 View Code Duplication
function dbPrepareData($data) {
0 ignored issues
show
The function dbPrepareData() has been defined more than once; this definition is ignored, only the first definition in includes/dbFacile.mysql.php (L477-504) is considered.

This check looks for functions that have already been defined in other files.

Some Codebases, like WordPress, make a practice of defining functions multiple times. This may lead to problems with the detection of function parameters and types. If you really need to do this, you can mark the duplicate definition with the @ignore annotation.

/**
 * @ignore
 */
function getUser() {

}

function getUser($id, $realm) {

}

See also the PhpDoc documentation for @ignore.

Loading history...
480
    global $database_link;
481
    $values = array();
482
483
    foreach ($data as $key => $value) {
484
        $escape = true;
485
        // don't quote or esc if value is an array, we treat it
486
        // as a "decorator" that tells us not to escape the
487
        // value contained in the array
488
        if (is_array($value) && !is_object($value)) {
489
            $escape = false;
490
            $value  = array_shift($value);
491
        }
492
493
        // it's not right to worry about invalid fields in this method because we may be operating on fields
494
        // that are aliases, or part of other tables through joins
495
        // if(!in_array($key, $columns)) // skip invalid fields
496
        // continue;
497
        if ($escape) {
498
            $values[$key] = "'".mysqli_real_escape_string($database_link,$value)."'";
499
        }
500
        else {
501
            $values[$key] = $value;
502
        }
503
    }
504
505
    return $values;
506
507
}//end dbPrepareData()
508
509
510
/*
511
 * Given a data array, this returns an array of placeholders
512
 * These may be question marks, or ":email" type
513
 */
514
515
516 View Code Duplication
function dbPlaceHolders($values) {
0 ignored issues
show
The function dbPlaceHolders() has been defined more than once; this definition is ignored, only the first definition in includes/dbFacile.mysql.php (L513-526) is considered.

This check looks for functions that have already been defined in other files.

Some Codebases, like WordPress, make a practice of defining functions multiple times. This may lead to problems with the detection of function parameters and types. If you really need to do this, you can mark the duplicate definition with the @ignore annotation.

/**
 * @ignore
 */
function getUser() {

}

function getUser($id, $realm) {

}

See also the PhpDoc documentation for @ignore.

Loading history...
517
    $data = array();
518
    foreach ($values as $key => $value) {
519
        if (is_numeric($key)) {
520
            $data[] = '?';
521
        }
522
        else {
523
            $data[] = ':'.$key;
524
        }
525
    }
526
527
    return $data;
528
529
}//end dbPlaceHolders()
530
531
532
function dbBeginTransaction() {
0 ignored issues
show
The function dbBeginTransaction() has been defined more than once; this definition is ignored, only the first definition in includes/dbFacile.mysql.php (L529-532) is considered.

This check looks for functions that have already been defined in other files.

Some Codebases, like WordPress, make a practice of defining functions multiple times. This may lead to problems with the detection of function parameters and types. If you really need to do this, you can mark the duplicate definition with the @ignore annotation.

/**
 * @ignore
 */
function getUser() {

}

function getUser($id, $realm) {

}

See also the PhpDoc documentation for @ignore.

Loading history...
533
    global $database_link;
534
    mysqli_query($database_link, 'begin');
535
536
}//end dbBeginTransaction()
537
538
539
function dbCommitTransaction() {
0 ignored issues
show
The function dbCommitTransaction() has been defined more than once; this definition is ignored, only the first definition in includes/dbFacile.mysql.php (L535-538) is considered.

This check looks for functions that have already been defined in other files.

Some Codebases, like WordPress, make a practice of defining functions multiple times. This may lead to problems with the detection of function parameters and types. If you really need to do this, you can mark the duplicate definition with the @ignore annotation.

/**
 * @ignore
 */
function getUser() {

}

function getUser($id, $realm) {

}

See also the PhpDoc documentation for @ignore.

Loading history...
540
    global $database_link;
541
    mysqli_query($database_link, 'commit');
542
543
}//end dbCommitTransaction()
544
545
546
function dbRollbackTransaction() {
0 ignored issues
show
The function dbRollbackTransaction() has been defined more than once; this definition is ignored, only the first definition in includes/dbFacile.mysql.php (L541-544) is considered.

This check looks for functions that have already been defined in other files.

Some Codebases, like WordPress, make a practice of defining functions multiple times. This may lead to problems with the detection of function parameters and types. If you really need to do this, you can mark the duplicate definition with the @ignore annotation.

/**
 * @ignore
 */
function getUser() {

}

function getUser($id, $realm) {

}

See also the PhpDoc documentation for @ignore.

Loading history...
547
    global $database_link;
548
    mysqli_query($database_link, 'rollback');
549
550
}//end dbRollbackTransaction()
551
552
553
/*
554
    class dbIterator implements Iterator {
555
    private $result;
556
    private $i;
557
558
    public function __construct($r) {
559
    $this->result = $r;
560
    $this->i = 0;
561
    }
562
    public function rewind() {
563
    mysql_data_seek($this->result, 0);
564
    $this->i = 0;
565
    }
566
    public function current() {
567
    $a = mysql_fetch_assoc($this->result);
568
    return $a;
569
    }
570
    public function key() {
571
    return $this->i;
572
    }
573
    public function next() {
574
    $this->i++;
575
    $a = mysql_data_seek($this->result, $this->i);
576
    if($a === false) {
577
    $this->i = 0;
578
    }
579
    return $a;
580
    }
581
    public function valid() {
582
    return ($this->current() !== false);
583
    }
584
    }
585
 */
586