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

_keyIndex() protected method

Works only for the main row data and not for relationship rows. This method will also correctly detect a primary key which doesn't come first.
protected _keyIndex ( ) : array
return array An array where key are index and value are primary key fieldname.
    protected function _keyIndex()
    {
        if (!($model = $this->_model) || !isset($this->_columns[''])) {
            return array();
        }
        $index = 0;
        foreach ($this->_columns as $name => $fields) {
            if ($name === '') {
                if (($offset = array_search($model::meta('key'), $fields)) === false) {
                    return array();
                }
                return array($index + $offset => $model::meta('key'));
            }
            $index += count($fields);
        }
        return array();
    }