public function read($query, array $options = []) {
		$defaults = [
			'return' => is_string($query) ? 'array' : 'item',
			'schema' => null,
			'quotes' => $this->_quotes
		];
		$options += $defaults;

		$params = compact('query', 'options');

		return Filters::run($this, __FUNCTION__, $params, function($params) {
			$query = $params['query'];
			$args = $params['options'];
			$return = $args['return'];
			unset($args['return']);

			$model = is_object($query) ? $query->model() : null;

			if (is_string($query)) {
				$sql = Text::insert($query, $this->value($args));
			} else {
				if (!$data = $this->_queryExport($query)) {
					return false;
				}
				$sql = $this->renderCommand($data['type'], $data);
			}
			$result = $this->_execute($sql);

			if ($return === 'resource') {
				return $result;
			}
			if ($return === 'item') {
				return $model::create([], compact('query', 'result') + [
					'class' => 'set', 'defaults' => false
				]);
			}
			$columns = $args['schema'] ?: $this->schema($query, $result);

			if (!is_array(reset($columns))) {
				$columns = ['' => $columns];
			}

			$i = 0;
			$records = [];

			foreach ($result as $data) {
				$offset = 0;
				$records[$i] = [];

				foreach ($columns as $path => $cols) {
					$len = count($cols);
					$values = array_combine($cols, array_slice($data, $offset, $len));
					($path) ? $records[$i][$path] = $values : $records[$i] += $values;
					$offset += $len;
				}
				$i++;
			}
			return Set::expand($records);
		});
	}
public function read($query, array $options = []) {
		$defaults = [
			'return' => is_string($query) ? 'array' : 'item',
			'schema' => null,
			'quotes' => $this->_quotes
		];
		$options += $defaults;

		$params = compact('query', 'options');

		return Filters::run($this, __FUNCTION__, $params, function($params) {
			$query = $params['query'];
			$args = $params['options'];
			$return = $args['return'];
			unset($args['return']);

			$model = is_object($query) ? $query->model() : null;

			if (is_string($query)) {
				$sql = Text::insert($query, $this->value($args));
			} else {
				if (!$data = $this->_queryExport($query)) {
					return false;
				}
				$sql = $this->renderCommand($data['type'], $data);
			}
			$result = $this->_execute($sql);

			if ($return === 'resource') {
				return $result;
			}
			if ($return === 'item') {
				return $model::create([], compact('query', 'result') + [
					'class' => 'set', 'defaults' => false
				]);
			}
			$columns = $args['schema'] ?: $this->schema($query, $result);

			if (!is_array(reset($columns))) {
				$columns = ['' => $columns];
			}

			$i = 0;
			$records = [];

			foreach ($result as $data) {
				$offset = 0;
				$records[$i] = [];

				foreach ($columns as $path => $cols) {
					$len = count($cols);
					$values = array_combine($cols, array_slice($data, $offset, $len));
					($path) ? $records[$i][$path] = $values : $records[$i] += $values;
					$offset += $len;
				}
				$i++;
			}
			return Set::expand($records);
		});
	}
public function read ( $ query , array $ options = [ ] ) { $ defaults = [ 'return' => is_string ( $ query ) ? 'array' : 'item' , 'schema' => null , 'quotes' => $ this -> _quotes ] ; $ options += $ defaults ; $ params = compact ( 'query' , 'options' ) ; return Filters :: run ( $ this , __FUNCTION__ , $ params , function ( $ params ) { $ query = $ params [ 'query' ] ; $ args = $ params [ 'options' ] ; $ return = $ args [ 'return' ] ; unset ( $ args [ 'return' ] ) ; $ model = is_object ( $ query ) ? $ query -> model ( ) : null ; if ( is_string ( $ query ) ) { $ sql = Text :: insert ( $ query , $ this -> value ( $ args ) ) ; } else { if ( ! $ data = $ this -> _queryExport ( $ query ) ) { return false ; } $ sql = $ this -> renderCommand ( $ data [ 'type' ] , $ data ) ; } $ result = $ this -> _execute ( $ sql ) ; if ( $ return === 'resource' ) { return $ result ; } if ( $ return === 'item' ) { return $ model :: create ( [ ] , compact ( 'query' , 'result' ) + [ 'class' => 'set' , 'defaults' => false ] ) ; } $ columns = $ args [ 'schema' ] ? : $ this -> schema ( $ query , $ result ) ; if ( ! is_array ( reset ( $ columns ) ) ) { $ columns = [ '' => $ columns ] ; } $ i = 0 ; $ records = [ ] ; foreach ( $ result as $ data ) { $ offset = 0 ; $ records [ $ i ] = [ ] ; foreach ( $ columns as $ path => $ cols ) { $ len = count ( $ cols ) ; $ values = array_combine ( $ cols , array_slice ( $ data , $ offset , $ len ) ) ; ( $ path ) ? $ records [ $ i ] [ $ path ] = $ values : $ records [ $ i ] += $ values ; $ offset += $ len ; } $ i ++ ; } return Set :: expand ( $ records ) ; } ) ; }
Reads records from a database using a `lithium\data\model\Query` object or raw SQL string.

@param string|object $query `lithium\data\model\Query` object or SQL string.
@param array $options If `$query` is a raw string, contains the values that will be escaped
and quoted. Other options:
- `'return'` _string_: switch return between `'array'`, `'item'`, or
`'resource'` _string_: Defaults to `'item'`.
@return mixed Determined by `$options['return']`.
@filter
Reads records from a database using a lithium \ data \ model \ Query object or raw SQL string .