-
Notifications
You must be signed in to change notification settings - Fork 0
/
helper_functions.php
62 lines (50 loc) · 1.23 KB
/
helper_functions.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
<?php
/**
* Helper functions, assuming you have a global variable called $db.
*/
function db_query($query, $vars = array()) {
global $db;
return $db->query($query, $vars);
}
function db_rows($query, $vars = array()) {
global $db;
return $db->getAll($query, $vars);
}
function db_row($query, $vars = array()) {
global $db;
return $db->getRow($query, $vars);
}
function db_col($query, $vars = array()) {
global $db;
return $db->getCol($query, $vars);
}
function db_list($query, $vars = array(), $join = FALSE) {
global $db;
return $db->getList($query, $vars, $join);
}
function db_one($query, $vars = array()) {
global $db;
return $db->getOne($query, $vars);
}
function db_escape($value, $quote = TRUE) {
global $db;
return $db->escape($value, $quote);
}
function db_save($table, &$data, $where = NULL, $primaryKey = NULL) {
global $db;
return $db->save($table, $data, $where, $primaryKey);
}
function db_enum($table, $column) {
global $db;
return $db->enum($table, $column);
}
function db_queries() {
global $db;
return array_map(function($query) {
return preg_replace("/\n +/", ' ', $query);
}, $db->queries);
}
function db_transaction($action) {
global $db;
return $db->transaction($action);
}