src/FelixOnline/Base/BaseManager.php
public function getSQL()
    {
        $statement = [];

        if ($this->distinct) {
            $distinct = 'DISTINCT ';
        } else {
            $distinct = '';
        }

        $statement[] = "(SELECT $distinct`" . $this->table . "`.*";
        $statement[] = $this->getFrom();
        $statement[] = $this->getJoin();
        $statement[] = $this->getWhere();
        $statement[] = $this->getGroup(true);

        $statement[] = ")";

        foreach ($this->unions as $union) {
            $statement[] = "UNION ".$distinct;
            $statement[] = $union->getSQL();
        }

        if ($this->unions) {
            $statement[] = $this->getOrder(true);
        } else {
            $statement[] = $this->getOrder(false);
        }

        $statement[] = $this->getRandom();
        $statement[] = $this->getLimit();

        // Remove null values
        $statement = array_filter($statement);

        return implode("\n", $statement);
    }
public function getSQL()
    {
        $statement = [];

        if ($this->distinct) {
            $distinct = 'DISTINCT ';
        } else {
            $distinct = '';
        }

        $statement[] = "(SELECT $distinct`" . $this->table . "`.*";
        $statement[] = $this->getFrom();
        $statement[] = $this->getJoin();
        $statement[] = $this->getWhere();
        $statement[] = $this->getGroup(true);

        $statement[] = ")";

        foreach ($this->unions as $union) {
            $statement[] = "UNION ".$distinct;
            $statement[] = $union->getSQL();
        }

        if ($this->unions) {
            $statement[] = $this->getOrder(true);
        } else {
            $statement[] = $this->getOrder(false);
        }

        $statement[] = $this->getRandom();
        $statement[] = $this->getLimit();

        // Remove null values
        $statement = array_filter($statement);

        return implode("\n", $statement);
    }
Get sql