lithium\data\collection\RecordSet::_mapRecord PHP Method

_mapRecord() protected method

1. Builds an associative array with data from the row, with joined row data nested under the relationships name. Joined row data is added and new results consumed from the result cursor under the relationships name until the value of the main primary key changes. 2. The built array is then hydrated and returned. Note: Joined records must appear sequentially, when non-sequential records are detected an exception is thrown.
protected _mapRecord ( array $row ) : object
$row array 2 dimensional PDO `Result` array
return object Returns a `Record` object
    protected function _mapRecord($row)
    {
        $main = array_intersect_key($row, $this->_keyIndex);
        if ($main) {
            if (in_array($main, $this->_seen)) {
                $message = 'Associated records hydrated out of order: ';
                $message .= var_export($this->_seen, true);
                throw new RuntimeException($message);
            }
            $this->_seen[] = $main;
        }
        $i = 0;
        $record = array();
        do {
            $offset = 0;
            foreach ($this->_columns as $name => $fields) {
                $record[$i][$name] = array_combine($fields, array_slice($row, $offset, $count = count($fields)));
                $offset += $count;
            }
            $i++;
            if (!($peek = $this->_result->peek())) {
                break;
            }
            if ($main !== array_intersect_key($peek, $this->_keyIndex)) {
                break;
            }
        } while ($main && ($row = $this->_result->next()));
        return $this->_hydrateRecord($this->_dependencies, $this->_model, $record, 0, $i, '');
    }