Subversion Repositories prepend

Rev

Rev 13 | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
2 daniel-mar 1
<?php
2
 
3
// TODO: test everything
4
// TODO: return values?
5
// TODO: check if we matched all stuff mentioned here: https://www.phpclasses.org/blog/package/9199/post/3-Smoothly-Migrate-your-PHP-Code-using-the-Old-MySQL-extension-to-MySQLi.html
9 daniel-mar 6
// TODO: translate descriptions to english
2 daniel-mar 7
 
9 daniel-mar 8
$xxx_vts_prepend_config = array();
10 daniel-mar 9
if (file_exists($xxx_vts_prepend_config_file = __DIR__.'/../config.local.php')) include $xxx_vts_prepend_config_file;
9 daniel-mar 10
unset($xxx_vts_prepend_config_file);
12 daniel-mar 11
$xxx_directories_need_mysql = $xxx_vts_prepend_config['directories_need_mysql'] ?? array(); /* @phpstan-ignore-line */
9 daniel-mar 12
unset($xxx_vts_prepend_config);
2 daniel-mar 13
 
9 daniel-mar 14
$xxx_go = false;
12 daniel-mar 15
foreach ($xxx_directories_need_mysql as $xxx_directory_need_mysql) { /* @phpstan-ignore-line */
9 daniel-mar 16
        if ($xxx_negate = (substr($xxx_directory_need_mysql,0,1) === '!')) {
17
                $xxx_directory_need_mysql = substr($xxx_directory_need_mysql,1);
18
        }
15 daniel-mar 19
        if (strpos($_SERVER['SCRIPT_FILENAME']??'', $xxx_directory_need_mysql) === 0) {
9 daniel-mar 20
                $xxx_go = !$xxx_negate;
21
        }
15 daniel-mar 22
        if (strpos(rtrim($_SERVER['PWD']??'',DIRECTORY_SEPARATOR), rtrim($xxx_directory_need_mysql,DIRECTORY_SEPARATOR)) === 0) {
13 daniel-mar 23
                $xxx_go = !$xxx_negate;
24
        }
9 daniel-mar 25
        unset($xxx_negate);
2 daniel-mar 26
}
9 daniel-mar 27
unset($xxx_directories_need_mysql);
28
unset($xxx_directory_need_mysql);
2 daniel-mar 29
 
12 daniel-mar 30
if ($xxx_go && !function_exists('mysql_connect')) { /* @phpstan-ignore-line */
2 daniel-mar 31
 
9 daniel-mar 32
        $vts_mysqli = null;
33
        $vts_mysqli_report_set_once = false;
2 daniel-mar 34
 
9 daniel-mar 35
        // Liefert die Anzahl betroffener Datensätze einer vorhergehenden MySQL Operation
36
        function mysql_affected_rows($link_identifier=NULL) {
37
                global $vts_mysqli;
38
                $li = is_null($link_identifier) ? $vts_mysqli : $link_identifier;
39
                if (is_null($li)) throw new Exception("Cannot execute mysql_affected_rows(). No valid connection to server.");
40
                return $li->affected_rows;
41
        }
2 daniel-mar 42
 
9 daniel-mar 43
        // Liefert den Namen des Zeichensatzes
44
        function mysql_client_encoding($link_identifier=NULL) {
45
                global $vts_mysqli;
46
                $li = is_null($link_identifier) ? $vts_mysqli : $link_identifier;
47
                if (is_null($li)) throw new Exception("Cannot execute mysql_client_encoding(). No valid connection to server.");
48
                return $li->character_set_name();
49
        }
2 daniel-mar 50
 
9 daniel-mar 51
        // Schließt eine Verbindung zu MySQL
52
        function mysql_close($link_identifier=NULL) {
53
                global $vts_mysqli;
54
                $li = is_null($link_identifier) ? $vts_mysqli : $link_identifier;
55
                if (is_null($li)) throw new Exception("Cannot execute mysql_close(). No valid connection to server.");
56
                return $li->close();
8 daniel-mar 57
        }
2 daniel-mar 58
 
9 daniel-mar 59
        // Öffnet eine Verbindung zu einem MySQL-Server
60
        function mysql_connect($server=null, $username=null, $password=null, $new_link=false, $client_flags=0) {
61
                global $vts_mysqli;
62
                global $vts_mysqli_report_set_once;
63
                $ary = explode(':', $server);
64
                $host = $ary[0];
65
                $ini_port = ini_get("mysqli.default_port");
66
                $port = isset($ary[1]) ? (int)$ary[1] : ($ini_port ? (int)$ini_port : 3306);
67
                if (is_null($server)) $port = ini_get("mysqli.default_host");
68
                if (is_null($username)) $port = ini_get("mysqli.default_user");
69
                if (is_null($password)) $port = ini_get("mysqli.default_password");
70
                $vts_mysqli = new mysqli($host, $username, $password, /*dbname*/'', $port, ini_get("mysqli.default_socket"));
71
                if (!$vts_mysqli_report_set_once) {
72
                        mysqli_report(MYSQLI_REPORT_OFF); // PHP <8.1 compatibility
73
                        $vts_mysqli_report_set_once = true;
74
                }
75
                return (empty($vts_mysqli->connect_error) && ($vts_mysqli->connect_errno == 0)) ? $vts_mysqli : false;
76
        }
2 daniel-mar 77
 
9 daniel-mar 78
        // Anlegen einer MySQL-Datenbank
79
        function mysql_create_db($database_name, $link_identifier=NULL) {
80
                global $vts_mysqli;
81
                $li = is_null($link_identifier) ? $vts_mysqli : $link_identifier;
82
                if (is_null($li)) throw new Exception("Cannot execute mysql_create_db(). No valid connection to server.");
83
                return mysql_query("CREATE DATABASE `$database_name`", $li) !== false;
84
        }
2 daniel-mar 85
 
9 daniel-mar 86
        // Bewegt den internen Ergebnis-Zeiger
87
        function mysql_data_seek($result, $row_number) {
88
                if (!$result) {
89
                        $err = mysql_error();
90
                        throw new Exception("Called mysql_data_seek() with an erroneous argument.".($err == '' ? '' : " Possible cause: $err"));
91
                }
92
                return $result->data_seek($row_number) !== false;
2 daniel-mar 93
        }
94
 
9 daniel-mar 95
        // Liefert Schema Namen vom Aufruf von mysql_list_dbs
96
        function mysql_db_name($result, $row, $field=NULL) {
97
                if (!$result) {
98
                        $err = mysql_error();
99
                        throw new Exception("Called mysql_db_name() with an erroneous argument.".($err == '' ? '' : " Possible cause: $err"));
100
                }
101
                $result->data_seek($row);
102
                return mysql_fetch_array($result)[is_null($field) ? 0 : $field];
2 daniel-mar 103
        }
104
 
9 daniel-mar 105
        // Selektiert ein Schema und führt in ihm Anfrage aus
106
        function mysql_db_query($database, $query, $link_identifier=NULL) {
107
                global $vts_mysqli;
108
                $li = is_null($link_identifier) ? $vts_mysqli : $link_identifier;
109
                if (is_null($li)) throw new Exception("Cannot execute mysql_db_query(). No valid connection to server.");
110
                mysql_select_db($database, $li);
111
                return mysql_query($query, $li);
112
                // Note: The mysql_*() implementation defines, that we will not jump back to our original DB
113
        }
2 daniel-mar 114
 
9 daniel-mar 115
        // Löschen eines Schemas
116
        function mysql_drop_db($database_name, $link_identifier=NULL) {
117
                global $vts_mysqli;
118
                $li = is_null($link_identifier) ? $vts_mysqli : $link_identifier;
119
                if (is_null($li)) throw new Exception("Cannot execute mysql_drop_db(). No valid connection to server.");
120
                return mysql_query("DROP DATABASE `$database_name`", $li) !== false;
121
        }
2 daniel-mar 122
 
9 daniel-mar 123
        // Liefert die Nummer einer Fehlermeldung einer zuvor ausgeführten MySQL Operation
124
        function mysql_errno($link_identifier=NULL) {
125
                global $vts_mysqli;
126
                $li = is_null($link_identifier) ? $vts_mysqli : $link_identifier;
127
                if (is_null($li)) throw new Exception("Cannot execute mysql_errno(). No valid connection to server.");
128
                return !empty($li->connect_errno) ? $li->connect_errno : $li->errno;
129
        }
2 daniel-mar 130
 
9 daniel-mar 131
        // Liefert den Fehlertext der zuvor ausgeführten MySQL Operation
132
        function mysql_error($link_identifier=NULL) {
133
                global $vts_mysqli;
134
                $li = is_null($link_identifier) ? $vts_mysqli : $link_identifier;
135
                if (is_null($li)) throw new Exception("Cannot execute mysql_error(). No valid connection to server.");
136
                return !empty($li->connect_error) ? $li->connect_error : $li->error;
137
        }
2 daniel-mar 138
 
9 daniel-mar 139
        // Maskiert einen String zur Benutzung in einer MySQL Abfrage
140
        function mysql_escape_string($unescaped_string) {
141
                global $vts_mysqli;
142
                return $vts_mysqli->real_escape_string($unescaped_string);
143
        }
2 daniel-mar 144
 
9 daniel-mar 145
        // Liefert einen Datensatz als assoziatives Array, als numerisches Array oder beides
146
        define('MYSQL_ASSOC', MYSQLI_ASSOC);
147
        define('MYSQL_NUM',   MYSQLI_NUM);
148
        define('MYSQL_BOTH',  MYSQLI_BOTH);
149
        function mysql_fetch_array($result, $result_type=MYSQL_BOTH) {
150
                if (!$result) {
151
                        $err = mysql_error();
152
                        throw new Exception("Called mysql_fetch_array() with an erroneous argument.".($err == '' ? '' : " Possible cause: $err"));
153
                }
154
                return $result->fetch_array($result_type);
155
        }
2 daniel-mar 156
 
9 daniel-mar 157
        // Liefert einen Datensatz als assoziatives Array
158
        function mysql_fetch_assoc($result) {
159
                if (!$result) {
160
                        $err = mysql_error();
161
                        throw new Exception("Called mysql_fetch_assoc() with an erroneous argument.".($err == '' ? '' : " Possible cause: $err"));
162
                }
163
                return $result->fetch_assoc();
164
        }
2 daniel-mar 165
 
9 daniel-mar 166
        // Liefert ein Objekt mit Feldinformationen aus einem Anfrageergebnis
167
        function mysql_fetch_field($result, $field_offset=0) {
168
                if (!$result) {
169
                        $err = mysql_error();
170
                        throw new Exception("Called mysql_fetch_field() with an erroneous argument.".($err == '' ? '' : " Possible cause: $err"));
171
                }
172
                return $result->fetch_field();
173
        }
2 daniel-mar 174
 
9 daniel-mar 175
        // Liefert die Länge eines jeden Feldes in einem Ergebnis
176
        function mysql_fetch_lengths($result) {
177
                if (!$result) {
178
                        $err = mysql_error();
179
                        throw new Exception("Called mysql_fetch_lengths() with an erroneous argument.".($err == '' ? '' : " Possible cause: $err"));
180
                }
181
                return $result->lengths;
182
        }
2 daniel-mar 183
 
9 daniel-mar 184
        // Liefert eine Ergebniszeile als Objekt
185
        function mysql_fetch_object($result, $class_name="stdClass", $params=null) {
186
                if (!$result) {
187
                        $err = mysql_error();
188
                        throw new Exception("Called mysql_fetch_object() with an erroneous argument.".($err == '' ? '' : " Possible cause: $err"));
189
                }
190
                if ($params) {
191
                        return $result->fetch_object($class_name, $params);
192
                } else {
193
                        return $result->fetch_object($class_name);
194
                }
2 daniel-mar 195
        }
196
 
9 daniel-mar 197
        // Liefert einen Datensatz als indiziertes Array
198
        function mysql_fetch_row($result) {
199
                if (!$result) {
200
                        $err = mysql_error();
201
                        throw new Exception("Called mysql_fetch_row() with an erroneous argument.".($err == '' ? '' : " Possible cause: $err"));
202
                }
203
                return $result->fetch_row();
2 daniel-mar 204
        }
205
 
9 daniel-mar 206
        // Liefert die Flags des spezifizierten Feldes in einem Anfrageergebnis
207
        function mysql_field_flags($result, $field_offset) {
208
                if (!$result) {
209
                        $err = mysql_error();
210
                        throw new Exception("Called mysql_field_flags() with an erroneous argument.".($err == '' ? '' : " Possible cause: $err"));
211
                }
212
                return $result->fetch_field_direct($field_offset)->flags;
2 daniel-mar 213
        }
214
 
9 daniel-mar 215
        // Liefert die Länge des angegebenen Feldes
216
        function mysql_field_len($result, $field_offset) {
217
                if (!$result) {
218
                        $err = mysql_error();
219
                        throw new Exception("Called mysql_field_len() with an erroneous argument.".($err == '' ? '' : " Possible cause: $err"));
220
                }
221
                return $result->fetch_field_direct($field_offset)->length;
2 daniel-mar 222
        }
223
 
9 daniel-mar 224
        // Liefert den Namen eines Feldes in einem Ergebnis
225
        function mysql_field_name($result, $field_offset) {
226
                if (!$result) {
227
                        $err = mysql_error();
228
                        throw new Exception("Called mysql_field_name() with an erroneous argument.".($err == '' ? '' : " Possible cause: $err"));
229
                }
230
                return $result->fetch_field_direct($field_offset)->name; //or "orgname"
2 daniel-mar 231
        }
9 daniel-mar 232
 
233
        // Setzt den Ergebniszeiger auf ein bestimmtes Feldoffset
234
        function mysql_field_seek($result, $field_offset) {
235
                if (!$result) {
236
                        $err = mysql_error();
237
                        throw new Exception("Called mysql_field_seek() with an erroneous argument.".($err == '' ? '' : " Possible cause: $err"));
238
                }
239
                return $result->field_seek($field_offset);
2 daniel-mar 240
        }
241
 
9 daniel-mar 242
        // Liefert den Namen der Tabelle, die das genannte Feld enthält
243
        function mysql_field_table($result, $field_offset) {
244
                if (!$result) {
245
                        $err = mysql_error();
246
                        throw new Exception("Called mysql_field_table() with an erroneous argument.".($err == '' ? '' : " Possible cause: $err"));
247
                }
248
                return $result->fetch_field_direct($field_offset)->table; // or "orgtable"
2 daniel-mar 249
        }
250
 
9 daniel-mar 251
        // Liefert den Typ des spezifizierten Feldes in einem Ergebnis
252
        function mysql_field_type($result, $field_offset) {
253
                if (!$result) {
254
                        $err = mysql_error();
255
                        throw new Exception("Called mysql_field_type() with an erroneous argument.".($err == '' ? '' : " Possible cause: $err"));
256
                }
257
                return $result->fetch_field_direct($field_offset)->type;
2 daniel-mar 258
        }
259
 
9 daniel-mar 260
        // Gibt belegten Speicher wieder frei
261
        function mysql_free_result($result) {
262
                if (!$result) {
263
                        $err = mysql_error();
264
                        throw new Exception("Called mysql_free_result() with an erroneous argument.".($err == '' ? '' : " Possible cause: $err"));
265
                }
266
                return $result->free();
2 daniel-mar 267
        }
268
 
9 daniel-mar 269
        // Liefert MySQL Clientinformationen
270
        function mysql_get_client_info() {
271
                global $vts_mysqli;
272
                return $vts_mysqli->get_client_info();
2 daniel-mar 273
        }
274
 
9 daniel-mar 275
        // Liefert MySQL Host Informationen
276
        function mysql_get_host_info($link_identifier=NULL) {
277
                global $vts_mysqli;
278
                $li = is_null($link_identifier) ? $vts_mysqli : $link_identifier;
279
                if (is_null($li)) throw new Exception("Cannot execute mysql_get_host_info(). No valid connection to server.");
280
                return $li->host_info;
2 daniel-mar 281
        }
282
 
9 daniel-mar 283
        // Liefert MySQL Protokollinformationen
284
        function mysql_get_proto_info($link_identifier=NULL) {
285
                global $vts_mysqli;
286
                $li = is_null($link_identifier) ? $vts_mysqli : $link_identifier;
287
                if (is_null($li)) throw new Exception("Cannot execute mysql_get_proto_info(). No valid connection to server.");
288
                return $li->protocol_version;
2 daniel-mar 289
        }
290
 
9 daniel-mar 291
        // Liefert MySQL Server Informationen
292
        function mysql_get_server_info($link_identifier=NULL) {
293
                global $vts_mysqli;
294
                $li = is_null($link_identifier) ? $vts_mysqli : $link_identifier;
295
                if (is_null($li)) throw new Exception("Cannot execute mysql_get_server_info(). No valid connection to server.");
296
                return $li->server_info;
2 daniel-mar 297
        }
298
 
9 daniel-mar 299
        // Liefert Informationen über die zuletzt ausgeführte Anfrage zurück
300
        function mysql_info($link_identifier=NULL) {
301
                global $vts_mysqli;
302
                $li = is_null($link_identifier) ? $vts_mysqli : $link_identifier;
303
                if (is_null($li)) throw new Exception("Cannot execute mysql_info(). No valid connection to server.");
304
                return $li->info;
2 daniel-mar 305
        }
306
 
9 daniel-mar 307
        // Liefert die ID, die in der vorherigen Abfrage erzeugt wurde
308
        function mysql_insert_id($link_identifier=NULL) {
309
                global $vts_mysqli;
310
                $li = is_null($link_identifier) ? $vts_mysqli : $link_identifier;
311
                if (is_null($li)) throw new Exception("Cannot execute mysql_insert_id(). No valid connection to server.");
312
                return $li->insert_id;
313
        }
2 daniel-mar 314
 
9 daniel-mar 315
        // Auflistung der verfügbaren Datenbanken (Schemata) auf einem MySQL Server
316
        function mysql_list_dbs($link_identifier=NULL) {
317
                global $vts_mysqli;
318
                $li = is_null($link_identifier) ? $vts_mysqli : $link_identifier;
319
                if (is_null($li)) throw new Exception("Cannot execute mysql_list_dbs(). No valid connection to server.");
320
                return mysql_query('SHOW DATABASES', $li);
321
        }
2 daniel-mar 322
 
9 daniel-mar 323
        // Listet MySQL Tabellenfelder auf
324
        function mysql_list_fields($database_name, $table_name, $link_identifier=NULL) {
325
                global $vts_mysqli;
326
                $li = is_null($link_identifier) ? $vts_mysqli : $link_identifier;
327
                if (is_null($li)) throw new Exception("Cannot execute mysql_list_fields(). No valid connection to server.");
328
                return mysql_query("SHOW COLUMNS FROM `$database_name`.`$table_name`", $li);
329
        }
2 daniel-mar 330
 
9 daniel-mar 331
        // Zeigt die MySQL Prozesse an
332
        function mysql_list_processes($link_identifier=NULL) {
333
                global $vts_mysqli;
334
                $li = is_null($link_identifier) ? $vts_mysqli : $link_identifier;
335
                if (is_null($li)) throw new Exception("Cannot execute mysql_list_processes(). No valid connection to server.");
336
                return $li->thread_id;
337
        }
2 daniel-mar 338
 
9 daniel-mar 339
        // Listet Tabellen in einer MySQL Datenbank auf
340
        function mysql_list_tables($database, $link_identifier=NULL) {
341
                global $vts_mysqli;
342
                $li = is_null($link_identifier) ? $vts_mysqli : $link_identifier;
343
                if (is_null($li)) throw new Exception("Cannot execute mysql_list_tables(). No valid connection to server.");
344
                return mysql_query("SHOW TABLES FROM `$database`", $li);
345
        }
2 daniel-mar 346
 
9 daniel-mar 347
        // Liefert die Anzahl der Felder in einem Ergebnis
348
        function mysql_num_fields($result) {
349
                if (!$result) {
350
                        $err = mysql_error();
351
                        throw new Exception("Called mysql_num_fields() with an erroneous argument.".($err == '' ? '' : " Possible cause: $err"));
352
                }
353
                global $vts_mysqli;
354
                return $vts_mysqli->field_count;
355
        }
2 daniel-mar 356
 
9 daniel-mar 357
        // Liefert die Anzahl der Zeilen im Ergebnis
358
        function mysql_num_rows($result) {
359
                if (!$result) {
360
                        $err = mysql_error();
361
                        throw new Exception("Called mysql_num_rows() with an erroneous argument.".($err == '' ? '' : " Possible cause: $err"));
362
                }
363
                return $result->num_rows;
364
        }
2 daniel-mar 365
 
9 daniel-mar 366
        // Öffnet eine persistente Verbindung zum MySQL Server
367
        function mysql_pconnect($server=null, $username=null, $password=null, $client_flags=0) {
368
                global $vts_mysqli;
369
                $ary = explode(':', $server);
370
                $host = $ary[0];
371
                $ini_port = ini_get("mysqli.default_port");
372
                $port = isset($ary[1]) ? (int)$ary[1] : ($ini_port ? (int)$ini_port : 3306);
373
                if (is_null($server)) $port = ini_get("mysqli.default_host");
374
                if (is_null($username)) $port = ini_get("mysqli.default_user");
375
                if (is_null($password)) $port = ini_get("mysqli.default_password");
376
                $vts_mysqli = new mysqli('p:'.$host, $username, $password, /*dbname*/'', $port, ini_get("mysqli.default_socket"));
377
                return (empty($vts_mysqli->connect_error) && ($vts_mysqli->connect_errno == 0)) ? $vts_mysqli : false;
378
        }
2 daniel-mar 379
 
9 daniel-mar 380
        // Ping a server connection or reconnect if there is no connection
381
        function mysql_ping($link_identifier=NULL) {
382
                global $vts_mysqli;
383
                $li = is_null($link_identifier) ? $vts_mysqli : $link_identifier;
384
                if (is_null($li)) throw new Exception("Cannot execute mysql_ping(). No valid connection to server.");
385
                return $li->ping();
386
        }
2 daniel-mar 387
 
9 daniel-mar 388
        // Sendet eine Anfrage an MySQL
389
        function mysql_query($query, $link_identifier=NULL) {
390
                global $vts_mysqli;
391
                $li = is_null($link_identifier) ? $vts_mysqli : $link_identifier;
392
                if (is_null($li)) throw new Exception("Cannot execute mysql_query(). No valid connection to server.");
393
                return $li->query($query, $resultmode=MYSQLI_STORE_RESULT);
394
        }
2 daniel-mar 395
 
9 daniel-mar 396
        // Maskiert spezielle Zeichen innerhalb eines Strings für die Verwendung in einer SQL-Anweisung
397
        function mysql_real_escape_string($unescaped_string, $link_identifier=NULL) {
398
                global $vts_mysqli;
399
                $li = is_null($link_identifier) ? $vts_mysqli : $link_identifier;
400
                if (is_null($li)) throw new Exception("Cannot execute mysql_real_escape_string(). No valid connection to server.");
401
                return $li->escape_string($unescaped_string);
402
        }
2 daniel-mar 403
 
9 daniel-mar 404
        // Liefert Ergebnis
405
        function mysql_result($result, $row, $field=0) {
406
                if (!$result) {
407
                        $err = mysql_error();
408
                        throw new Exception("Called mysql_result() with an erroneous argument.".($err == '' ? '' : " Possible cause: $err"));
409
                }
410
                $result->data_seek($row);
411
                return mysql_fetch_array($result)[$field];
412
        }
2 daniel-mar 413
 
9 daniel-mar 414
        // Auswahl einer MySQL Datenbank
415
        function mysql_select_db($database_name, $link_identifier=NULL) {
416
                global $vts_mysqli;
417
                $li = is_null($link_identifier) ? $vts_mysqli : $link_identifier;
418
                if (is_null($li)) throw new Exception("Cannot execute mysql_select_db(). No valid connection to server.");
419
                return $li->select_db($database_name);
420
        }
2 daniel-mar 421
 
9 daniel-mar 422
        // Setzt den Verbindungszeichensatz
423
        function mysql_set_charset($charset, $link_identifier=NULL) {
424
                global $vts_mysqli;
425
                $li = is_null($link_identifier) ? $vts_mysqli : $link_identifier;
426
                if (is_null($li)) throw new Exception("Cannot execute mysql_set_charset(). No valid connection to server.");
427
                return $li->set_charset($charset);
428
        }
2 daniel-mar 429
 
9 daniel-mar 430
        // Zeigt den momentanen Serverstatus an
431
        function mysql_stat($link_identifier=NULL) {
432
                global $vts_mysqli;
433
                $li = is_null($link_identifier) ? $vts_mysqli : $link_identifier;
434
                if (is_null($li)) throw new Exception("Cannot execute mysql_stat(). No valid connection to server.");
435
                return $li->stat();
2 daniel-mar 436
        }
437
 
9 daniel-mar 438
        // Liefert den Namen einer Tabelle
439
        function mysql_tablename($result, $i) {
440
                if (!$result) {
441
                        $err = mysql_error();
442
                        throw new Exception("Called mysql_tablename() with an erroneous argument.".($err == '' ? '' : " Possible cause: $err"));
443
                }
444
                $result->data_seek($i);
445
                return mysql_fetch_array($result)[0];
2 daniel-mar 446
        }
447
 
9 daniel-mar 448
        // Zeigt die aktuelle Thread ID an
449
        function mysql_thread_id($link_identifier=NULL) {
450
                global $vts_mysqli;
451
                $li = is_null($link_identifier) ? $vts_mysqli : $link_identifier;
452
                if (is_null($li)) throw new Exception("Cannot execute mysql_thread_id(). No valid connection to server.");
453
                return $li->thread_id;
2 daniel-mar 454
        }
455
 
9 daniel-mar 456
        // Sendet eine SQL Anfrage an MySQL, ohne Ergebniszeilen abzuholen und zu puffern
457
        function mysql_unbuffered_query($query, $link_identifier=NULL) {
458
                global $vts_mysqli;
459
                $li = is_null($link_identifier) ? $vts_mysqli : $link_identifier;
460
                if (is_null($li)) throw new Exception("Cannot execute mysql_unbuffered_query(). No valid connection to server.");
461
                // http://php.net/manual/de/mysqlinfo.concepts.buffering.php
462
                // https://stackoverflow.com/questions/1982016/unbuffered-query-with-mysqli?utm_medium=organic&utm_source=google_rich_qa&utm_campaign=google_rich_qa
463
                $li->real_query($query);
464
                $li->use_result();
2 daniel-mar 465
        }
466
 
467
}
9 daniel-mar 468
unset($xxx_directories_need_mysql);
469
unset($xxx_directory_need_mysql);