lithium\data\collection\RecordSet::_keyIndex()

protected method

Extracts the numerical index of the primary key in numerical indexed row data. 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.

Returns

array

An array where key are index and value are primary key fieldname.

Source

	protected function _keyIndex() {
		if (!($model = $this->_model) || !isset($this->_columns[''])) {
			return [];
		}
		$index = 0;

		foreach ($this->_columns as $name => $fields) {
			if ($name === '') {
				if (($offset = array_search($model::meta('key'), $fields)) === false) {
					return [];
				}
				return [$index + $offset => $model::meta('key')];
			}
			$index += count($fields);
		}
		return [];
	}