-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathconfig.php
More file actions
50 lines (40 loc) · 934 Bytes
/
Copy pathconfig.php
File metadata and controls
50 lines (40 loc) · 934 Bytes
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
<?php
// create table connection
function executeQuery($query, $data, $fetchMode)
{
/*
To define $data use this format:
$d = [
[
"bind" => ":bind",
"value" => data
],
[
"bind" => ":bind",
"value" => data
]
];
fetchMode takes three values:
*fetch
*fetchNone
*fetchAll
*/
include 'databaseConn.php';
$statement = $conn->prepare($query);
for ($i=0; $i < count($data); $i++)
{
$statement->bindParam($data[$i]["bind"], $data[$i]["value"]);
}
$execute = $statement->execute();
if ($fetchMode == "fetch")
{
$val = $execute->fetch(PDO::FETCH_ASSOC);
} else if ($fetchMode == "fetchNone")
{
$val = $execute->fetchAll(PDO::FETCH_ASSOC);
} else {
$val = $execute;
}
return $val;
}
?>