protected function execute() { if ($this->rows !== NULL) { return; } $hash = md5($this->sqlBuilder->buildSelectQuery() . json_encode($this->sqlBuilder->getParameters())); $referencing =& $this->getRefTable($refPath)->referencing[$refPath . $hash]; $this->rows =& $referencing['rows']; $this->referenced =& $referencing['refs']; $this->accessed =& $referencing['accessed']; $refData =& $referencing['data']; if ($refData === NULL) { $limit = $this->sqlBuilder->getLimit(); $rows = count($this->refTable->rows); if ($limit && $rows > 1) { $this->sqlBuilder->setLimit(NULL, NULL); } parent::execute(); $this->sqlBuilder->setLimit($limit, NULL); $refData = array(); $offset = array(); foreach ($this->rows as $key => $row) { $ref =& $refData[$row[$this->column]]; $skip =& $offset[$row[$this->column]]; if ($limit === NULL || $rows <= 1 || count($ref) < $limit && $skip >= $this->sqlBuilder->getOffset()) { $ref[$key] = $row; } else { unset($this->rows[$key]); } $skip++; unset($ref, $skip); } } $this->data =& $refData[$this->active]; if ($this->data === NULL) { $this->data = array(); } else { foreach ($this->data as $row) { $row->setTable($this); // injects correct parent GroupedSelection } reset($this->data); } }