-
Notifications
You must be signed in to change notification settings - Fork 0
/
mysqli_wrapper.php
67 lines (67 loc) · 1.57 KB
/
mysqli_wrapper.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
<?php
define ('MYSQL_ASSOC', MYSQLI_ASSOC);
define ('MYSQL_NUM', MYSQLI_NUM);
define ('MYSQL_BOTH', MYSQLI_BOTH);
$mysqli = null;
function mysql_connect($a, $b, $c, $d = null) {
global $mysqli;
$mysqli = new mysqli($a, $b, $c, $d);
return $mysqli;
}
function mysql_select_db($a, $db = null) {
global $mysqli;
return ($db?:$mysqli)->select_db($a);
}
function mysql_query($q, $db = null) {
global $mysqli;
return ($db?:$mysqli)->query($q);
}
function mysql_insert_id($db = null) {
global $mysqli;
return ($db?:$mysqli)->insert_id;
}
function mysql_fetch_array($r, $rt) {
return $r->fetch_array($rt);
}
function mysql_numrows($r) {
return $r->num_rows;
}
function mysql_num_rows($r) {
return $r->num_rows;
}
function mysql_free_result($r) {
return $r->free();
}
function mysql_close($db = null) {
global $mysqli;
return ($db?:$mysqli)->close();
}
function mysql_real_escape_string($s, $db = null) {
global $mysqli;
return ($db?:$mysqli)->real_escape_string($s);
}
function mysql_fetch_assoc($r) {
return $r->fetch_assoc();
}
function mysql_fetch_row($r) {
return $r->fetch_row();
}
function mysql_num_fields($r) {
return $r->field_count;
}
function mysql_field_name($r, $offset) {
return $r->fetch_field_direct($offset)->name;
}
function mysql_affected_rows($db = null) {
global $mysqli;
return ($db?:$mysqli)->affected_rows;
}
function mysql_error($db = null) {
global $mysqli;
return ($db?:$mysqli)->error;
}
function mysql_result($r, $row, $field = 0) {
$r->field_seek($row);
return $r->fetch_array()[$field];
}
?>