ManaPHP\Mvc\Model\QueryBuilder::_getUnionSql PHP Method

_getUnionSql() protected method

protected _getUnionSql ( ) : string
return string
    protected function _getUnionSql()
    {
        $unions = [];
        /**
         * @var \ManaPHP\Mvc\Model\QueryBuilder $builder
         */
        /** @noinspection ForeachSourceInspection */
        foreach ($this->_union['builders'] as $builder) {
            $unions[] = '(' . $builder->getSql() . ')';
            /** @noinspection SlowArrayOperationsInLoopInspection */
            $this->_bind = array_merge($this->_bind, $builder->getBind());
        }
        $sql = implode(' ' . $this->_union['type'] . ' ', $unions);
        /**
         * Process order clause
         */
        if ($this->_order !== null) {
            $sql .= ' ORDER BY ' . $this->_order;
        }
        /**
         * Process limit parameters
         */
        if ($this->_limit !== 0) {
            $sql .= ' LIMIT ' . $this->_limit;
        }
        if ($this->_offset !== 0) {
            $sql .= ' OFFSET ' . $this->_offset;
        }
        $this->_models[] = $builder->getModels()[0];
        return $sql;
    }