- $opts = XDB::fetchAllAssoc('id', 'SELECT ' . $this->valfield . ' AS field,
- ' . $this->optfield . ' AS subid,
- ' . $this->idfield . ' AS id
- FROM ' . $this->from . '
- ' . $this->join . '
- ' . $this->where . '
- GROUP BY ' . $this->valfield . '
- ORDER BY ' . $this->valfield);
- $this->options = array();
- $this->suboptions = array();
- foreach ($opts as $id => $opt) {
- $this->options[$id] = $opt['field'];
- if (!array_key_exists($opt['subid'], $this->suboptions)) {
- $this->suboptions[$opt['subid']] = array();
- }
- $this->suboptions[$opt['subid']][$id] = $opt['field'];