cakephp/cakephp — pull request #5460 by Laykou (2014-12-21 18:14:40+00:00)
Title: Get the original query in ResultSet

Make the original `Query` available from the ResultSet.

My usecase is that I would like to access the original query table from the cell. So I can pass various ResultSets to the cell

```PHP`
$this->cell('MyCell', [$articles]);
$this->cell('MyCell', [$comments]);
```

and then in the cell I can access for example the original table and make some decisions:

```PHP
public function display($results) {
$table = $results->query()->repository();
$table->someCommonTableMethod();
}
```

my current workaround is
```PHP
$table = $results->__debugInfo()['query']->repository();
```
which doesn't look good.

But I am not sure if this works if the query was cached, because when the results are read from the cache it looks like the `$_query` in the `ResultSet` property is empty.