diff --git a/.travis.yml b/.travis.yml index 6ec8b21..46b23d3 100644 --- a/.travis.yml +++ b/.travis.yml @@ -5,6 +5,8 @@ php: - 5.5 - 5.6 - 7.0 + - 7.1 + - 7.2 - hhvm - nightly diff --git a/src/Query/Sql/Select.php b/src/Query/Sql/Select.php index f447b16..819917c 100644 --- a/src/Query/Sql/Select.php +++ b/src/Query/Sql/Select.php @@ -11,6 +11,8 @@ use ClanCats\Hydrahon\Query\Expression; +use ClanCats\Hydrahon\BaseQuery; + class Select extends SelectBase implements FetchableInterface { /** @@ -62,6 +64,37 @@ class Select extends SelectBase implements FetchableInterface */ protected $forwardKey = false; + /** + * Inherit property values from parent query + * + * @param BaseQuery $parent + * @return void + */ + protected function inheritFromParent(BaseQuery $parent) + { + parent::inheritFromParent($parent); + + if ($parent instanceof Select) { + $parent->copyTo($this); + } + } + + /** + * Copy current queries select attributes to the given one + * + * @param Select $query + */ + public function copyTo(Select $query) + { + $query->fields = $this->fields; + $query->distinct = $this->distinct; + $query->orders = $this->orders; + $query->groups = $this->groups; + $query->joins = $this->joins; + $query->groupResults = $this->groupResults; + $query->forwardKey = $this->forwardKey; + } + /** * Distinct select setter *