-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdatabase.php
73 lines (59 loc) · 1.4 KB
/
database.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
68
69
70
71
72
73
<?php
$dbName = 'scalabrinedb';
$dbHost = 'localhost';
$dbUsername = 'scala_master';
$dbUserPassword = 'Tw3n+ysof+9Ly';
$con = new mysqli($dbHost,$dbUsername,$dbUserPassword,$dbName);
function getNumRows($type, $param, $query)
{
global $con;
$stmt = $con->prepare($query);
call_user_func_array(array($stmt, "bind_param"), array_merge(array($type), $param));
$stmt->execute();
$stmt->store_result();
$numRows = $stmt->num_rows();
$stmt->close();
return $numRows;
}
function my_update($type, $param, $query)
{
global $con;
$stmt = $con->prepare($query);
call_user_func_array(array($stmt, "bind_param"), array_merge(array($type), $param));
$stmt->execute();
$err = $con->errno;
$stmt->close();
return $err;
}
function my_query($type, $param, $query)
{
global $con;
$stmt = $con->prepare($query);
call_user_func_array(array($stmt, "bind_param"), array_merge(array($type), $param));
$stmt->execute();
$meta = $stmt->result_metadata();
while ($field = $meta->fetch_field())
{
$params[] = &$row[$field->name];
}
call_user_func_array(array($stmt, 'bind_result'), $params);
while ($stmt->fetch()) {
foreach($row as $key => $val)
{
$result[$key] = $val;
}
}
$stmt->close();
return $result;
}
function my_disconnect()
{
global $con;
$con->close();
}
function sanitize($str)
{
global $con;
return $con->real_escape_string($str);
}
?>