queryAggregation = Query::getInstance()->table("__TMP__"); } public static function getInstance(): Union { return new Union(); } /** * @throws InvalidArgumentException */ public function addQuery(QueryBasic $query): Union { if (get_class($query) !== QueryBasic::class) { throw new InvalidArgumentException("The query must be an instance of " . QueryBasic::class); } $this->queryList[] = $query; return $this; } /** * Example: * $query->orderBy(['price desc']); * * @param array $fields * @return $this */ public function orderBy(array $fields): Union { $this->queryAggregation->orderBy($fields); return $this; } public function groupBy(array $fields): Union { $this->queryAggregation->groupBy($fields); return $this; } /** * @param int $start * @param int $end * @return $this * @throws InvalidArgumentException */ public function limit(int $start, int $end): Union { $this->queryAggregation->limit($start, $end); return $this; } /** * @param int $top * @return $this * @throws InvalidArgumentException */ public function top(int $top): Union { $this->queryAggregation->top($top); return $this; } /** * @throws InvalidArgumentException */ public function build(?DbDriverInterface $dbDriver = null): SqlObject { $unionQuery = []; $params = []; foreach ($this->queryList as $query) { $build = $query->build($dbDriver); $unionQuery[] = $build->getSql(); $params = array_merge($params, $build->getParameters()); } $unionQuery = implode(" UNION ", $unionQuery); $build = $this->queryAggregation->build($dbDriver); $unionQuery = trim($unionQuery . " " . substr($build->getSql(), strpos($build->getSql(), "__TMP__") + 8)); return new SqlObject($unionQuery, $params); } public function buildAndGetIterator( ?DbDriverInterface $dbDriver = null, ?CacheQueryResult $cache = null, ): GenericIterator { $sqlObject = $this->build($dbDriver); $sqlStatement = new SqlStatement($sqlObject->getSql()); if (!empty($cache)) { $sqlStatement->withCache($cache->getCache(), $cache->getCacheKey(), $cache->getTtl()); } return $sqlStatement->getIterator($dbDriver, $sqlObject->getParameters()); } }__halt_compiler();----SIGNATURE:----fOeXTdM4Rh/ut1Fm+VR79X3wUPabt59s3ZbyWfA+WikwYSjA4dY315Mvo4ff96Rq76Am2GXYFLcQzcEpSBeAueHe5n8SnDUTAI3hpF9kYoem1sJlmT+M/Q2FT3XWYPPfKXHj+pDljrrS59GFghsAaIL+U5GLlt5W9iMpL5uV4srX5afqitQSskRYwt8pmqVPmfPFheMwOx1YDMaoLq30qpmEzicj79+AdrgUnyXJcOM1z4vJIC+jYGJaMGPRx029zWvkpEC/8WLUEdT0oTfAFcyOps699tJv2z477IFOny7aZMziCn92T8+wNjYlBBm2Pm0BXpYV3qdKdhsoSFJmOQcQHk00XimrNTsMa6LjmxKnemzMy+mzA960TtDXioW86vFjxu1uM159W+ZoTQkmOH6fYfEG7hSlKRUB2rfISy8KSd2EwdrBe41MUrkHJR5SxhbBQjqw5Zv0EN1DbWMNIkvIMMPH/APDtIcuyQZc3Xl5//WOTkMtw1Qv2FGrjvIT+uEGeGrPhjmODBrSKEC78WN5wvXKTUZTc54kASO+pAlEJ2EVr4LXUklCkQLHt9F0O5XSvTja1Gnxl1IFYcGJnt6tq5oGXLuA68LKtwT2bc4yMb4/z6+1ZTjsEzBGfztswTCW24RX1X3d2BvW+axrgWG7J/a7wY6YDSnOPjw9cmE=----ATTACHMENT:----NTA4MzQ1NzkwNjQ0MzI3MyA3MDYyOTkyODE0OTA3NjgxIDk0OTQ1Mjc0MzAwNTkyNTg=