public function getUsers($fields = null, $where = null, $order = null, $count = null, $onlyOnline = false) { // the table 'presence' is populated every time a user access into the world if ($onlyOnline) { $sql = 'SELECT UUID FROM auth,useraccounts,presence WHERE UUID=PrincipalID AND UserID=UUID'; } else { $sql = 'SELECT UUID FROM auth,useraccounts WHERE UUID=PrincipalID'; } // where clause if ($where) { $sql .= ' AND (' . $where . ') '; } if ($order) { $sql .= " ORDER BY " . $order; } // how many results if ($count && $count > 0) { $sql .= " LIMIT {$count}"; } $usersId = $this->db->fetchCol($sql); $results = array(); foreach ($usersId as $id) { $results[] = $this->getUser($id, $fields); } return $results; }
public function getRegions($fields = null, $order = null, $count = null) { $sql = "SELECT uuid FROM regions"; // order if ($order) { $order = explode(',', $order); $orderFields = array(); foreach ($order as $o) { $field = trim(str_replace(array('ASC', 'DESC'), array('', ''), $o)); $orderFields[] = $o; } if (count($orderFields) > 0) { $sql .= " ORDER BY " . implode(',', $orderFields); } } // how many results if ($count && $count > 0) { $sql .= " LIMIT {$count}"; } $idList = $this->db->fetchCol($sql); $results = array(); foreach ($idList as $id) { if ($r = $this->getRegion($id, $fields)) { $results[] = $r; } } return $results; }