forked from Prev/engine-pmc
-
Notifications
You must be signed in to change notification settings - Fork 0
/
conf.functions.php
47 lines (38 loc) · 1.08 KB
/
conf.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
<?php
function printError($message) {
$obj = new StdClass();
$obj->result = 'fail';
$obj->error = new StdClass();
$obj->error->message = $message;
echo json_encode($obj);
exit;
}
function execQuery($query, $fetchType='object') {
$query = join($GLOBALS['db_prefix'], explode('(#)', $query));
$result = mysql_query($query, $GLOBALS['db']);
if (!$result || $result === true) return NULL;
if (mysql_num_rows($result) === NULL) return $result;
$arr = array();
switch ($fetchType) {
case 'object':
while ($fetch = mysql_fetch_object($result))
array_push($arr, $fetch);
break;
case 'array':
while ($fetch = mysql_fetch_array($result))
array_push($arr, $fetch);
break;
case 'row' :
while ($fetch = mysql_fetch_row($result))
array_push($arr, $fetch);
break;
}
return $arr;
}
function execQueryOne($query, $fetchType='object') {
$result = execQuery($query, $fetchType);
if (is_array($result) && count($result) !== 0)
return $result[0];
else
return $result;
}