/** * retrieve groups from the database * * @param CriteriaElement $criteria {@link CriteriaElement} with conditions for the groups * @param bool $id_as_key should the groups' IDs be used as keys for the associative array? * @return mixed Array of groups */ public function getObjects(CriteriaElement $criteria = null, $id_as_key = false) { $ret = array(); $limit = $start = 0; $sql = 'SELECT * FROM ' . $this->db->prefix('groups'); if (isset($criteria) && is_subclass_of($criteria, 'criteriaelement')) { $sql .= ' ' . $criteria->renderWhere(); $limit = $criteria->getLimit(); $start = $criteria->getStart(); } $result = $this->db->query($sql, $limit, $start); if (!$result) { return $ret; } while ($myrow = $this->db->fetchArray($result)) { $group = new XoopsGroup(); $group->assignVars($myrow); if (!$id_as_key) { $ret[] =& $group; } else { $ret[$myrow['groupid']] =& $group; } unset($group); } return $ret; }
/** * retrieve a specific group * * @param int $id ID of the group to get * @return object XoopsGroup reference to the group object, FALSE if failed */ function &get($id) { $ret = false; if (intval($id) > 0) { $sql = 'SELECT * FROM ' . $this->db->prefix('groups') . ' WHERE groupid=' . $id; if ($result = $this->db->query($sql)) { $numrows = $this->db->getRowsNum($result); if ($numrows == 1) { $group = new XoopsGroup(); $group->assignVars($this->db->fetchArray($result)); $ret =& $group; } } } return $ret; }