protected function _hydrateRecord(array $relations, $primary, array $record, $min, $max, $name) {
		$options = ['exists' => true, 'defaults' => false];

		foreach ($relations as $relation => $subrelations) {
			$relName  = $name ? "{$name}.{$relation}" : $relation;
			$relModel = $this->_relationships[$relName]['model'];
			$relField = $this->_relationships[$relName]['fieldName'];
			$relType  = $this->_relationships[$relName]['type'];

			if ($relType !== 'hasMany') {
				$record[$min][$name][$relField] = $this->_hydrateRecord(
					$subrelations ?: [], $relModel, $record, $min, $max, $relName
				);
				continue;
			}

			$rel = [];
			$main = $relModel::key($record[$min][$relName]);

			$i = $min;
			$j = $i + 1;

			while ($j < $max) {
				$keys = $relModel::key($record[$j][$relName]);

				if ($main != $keys) {
					$rel[] = $this->_hydrateRecord(
						$subrelations ?: [], $relModel, $record, $i, $j, $relName
					);
					$main = $keys;
					$i = $j;
				}
				$j++;
			}
			if (array_filter($record[$i][$relName])) {
				$rel[] = $this->_hydrateRecord(
					$subrelations ?: [], $relModel, $record, $i, $j, $relName
				);
			}
			$record[$min][$name][$relField] = $relModel::create($rel, [
				'class' => 'set'
			] + $options);
		}
		return $primary::create(
			isset($record[$min][$name]) ? $record[$min][$name] : [], $options
		);
	}
protected function _hydrateRecord(array $relations, $primary, array $record, $min, $max, $name) {
		$options = ['exists' => true, 'defaults' => false];

		foreach ($relations as $relation => $subrelations) {
			$relName  = $name ? "{$name}.{$relation}" : $relation;
			$relModel = $this->_relationships[$relName]['model'];
			$relField = $this->_relationships[$relName]['fieldName'];
			$relType  = $this->_relationships[$relName]['type'];

			if ($relType !== 'hasMany') {
				$record[$min][$name][$relField] = $this->_hydrateRecord(
					$subrelations ?: [], $relModel, $record, $min, $max, $relName
				);
				continue;
			}

			$rel = [];
			$main = $relModel::key($record[$min][$relName]);

			$i = $min;
			$j = $i + 1;

			while ($j < $max) {
				$keys = $relModel::key($record[$j][$relName]);

				if ($main != $keys) {
					$rel[] = $this->_hydrateRecord(
						$subrelations ?: [], $relModel, $record, $i, $j, $relName
					);
					$main = $keys;
					$i = $j;
				}
				$j++;
			}
			if (array_filter($record[$i][$relName])) {
				$rel[] = $this->_hydrateRecord(
					$subrelations ?: [], $relModel, $record, $i, $j, $relName
				);
			}
			$record[$min][$name][$relField] = $relModel::create($rel, [
				'class' => 'set'
			] + $options);
		}
		return $primary::create(
			isset($record[$min][$name]) ? $record[$min][$name] : [], $options
		);
	}
protected function _hydrateRecord ( array $ relations , $ primary , array $ record , $ min , $ max , $ name ) { $ options = [ 'exists' => true , 'defaults' => false ] ; foreach ( $ relations as $ relation => $ subrelations ) { $ relName = $ name ? "{$name}.{$relation}" : $ relation ; $ relModel = $ this -> _relationships [ $ relName ] [ 'model' ] ; $ relField = $ this -> _relationships [ $ relName ] [ 'fieldName' ] ; $ relType = $ this -> _relationships [ $ relName ] [ 'type' ] ; if ( $ relType !== 'hasMany' ) { $ record [ $ min ] [ $ name ] [ $ relField ] = $ this -> _hydrateRecord ( $ subrelations ? : [ ] , $ relModel , $ record , $ min , $ max , $ relName ) ; continue ; } $ rel = [ ] ; $ main = $ relModel :: key ( $ record [ $ min ] [ $ relName ] ) ; $ i = $ min ; $ j = $ i + 1 ; while ( $ j < $ max ) { $ keys = $ relModel :: key ( $ record [ $ j ] [ $ relName ] ) ; if ( $ main != $ keys ) { $ rel [ ] = $ this -> _hydrateRecord ( $ subrelations ? : [ ] , $ relModel , $ record , $ i , $ j , $ relName ) ; $ main = $ keys ; $ i = $ j ; } $ j ++ ; } if ( array_filter ( $ record [ $ i ] [ $ relName ] ) ) { $ rel [ ] = $ this -> _hydrateRecord ( $ subrelations ? : [ ] , $ relModel , $ record , $ i , $ j , $ relName ) ; } $ record [ $ min ] [ $ name ] [ $ relField ] = $ relModel :: create ( $ rel , [ 'class' => 'set' ] + $ options ) ; } return $ primary :: create ( isset ( $ record [ $ min ] [ $ name ] ) ? $ record [ $ min ] [ $ name ] : [ ] , $ options ) ; }
Hydrates a 2 dimensional PDO row `Result` array recursively.

@param array $relations The cascading with relation
@param string $primary Model classname
@param array $record Loaded Records
@param integer $min
@param integer $max
@param string $name Alias name
@return \lithium\data\entity\Record Returns a `Record` object as created by the model.
Hydrates a 2 dimensional PDO row Result array recursively .