Newer
Older
<?php
include_once("include/db.php");
function getAdminRealms($params) {
global $db;
# Filters and sorts are the same here
$filtersorts = array(
'ID' => 'realms.ID',
'Name' => 'realms.Name',
'Disabled' => 'realms.Disabled'
);
$res = DBSelectSearch("SELECT ID, Name, Disabled FROM realms",$params[1],$filtersorts,$filtersorts);
$sth = $res[0]; $numResults = $res[1];
# If STH is blank, return the error back to whoever requested the data
if (!isset($sth)) {
return $res;
}
# loop through rows
while ($row = $sth->fetchObject()) {
$item = array();
$item['ID'] = $row->id;
$item['Name'] = $row->name;
$item['Disabled'] = $row->disabled;
# push this row onto array
array_push($resultArray,$item);
}
return array($resultArray,$numResults);
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
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
# Return specific realm row
function getAdminRealm($params) {
global $db;
$res = DBSelect("SELECT ID, Name, Disabled FROM realms WHERE ID = ?",array($params[0]));
if (!is_object($res)) {
return $res;
}
$resultArray = array();
$row = $res->fetchObject();
$resultArray['ID'] = $row->id;
$resultArray['Name'] = $row->name;
$resultArray['Disabled'] = $row->disabled;
return $resultArray;
}
# Remove admin realm
function removeAdminRealm($params) {
global $db;
$res = DBDo("DELETE FROM realms WHERE ID = ?",array($params[0]));
if (!is_numeric($res)) {
return $res;
}
return NULL;
}
# Add admin realm
function createAdminRealm($params) {
global $db;
$res = DBDo("INSERT INTO realms (Name) VALUES (?)",array($params[0]['Name']));
if (!is_numeric($res)) {
return $res;
}
return NULL;
}
# Edit admin realm
function updateAdminRealm($params) {
global $db;
$res = DBDo("UPDATE realms SET Name = ? WHERE ID = ?",array($params[0]['Name'],$params[0]['ID']));
if (!is_numeric($res)) {
return $res;
}
return NULL;
}