src/Leevel/Database/Condition.php
public function makeSql(bool $withLogicGroup = false): string
    {
        $sql = [
            'SELECT',
        ];

        foreach (array_keys($this->options) as $option) {
            if ('from' === $option) {
                $sql['from'] = '';
            } elseif ('union' === $option) {
                continue;
            } else {
                $method = 'parse'.ucfirst($option);

                if (method_exists($this, $method)) {
                    $sql[$option] = $this->{$method}();
                }
            }
        }

        $sql['from'] = $this->parseFrom();

        // 删除空元素
        foreach ($sql as $offset => $option) {
            if ('' === trim($option)) {
                unset($sql[$offset]);
            }
        }

        $sql[] = $this->parseUnion();

        $result = trim(implode(' ', $sql));

        if (true === $withLogicGroup) {
            return static::LOGIC_GROUP_LEFT.$result.static::LOGIC_GROUP_RIGHT;
        }

        return $result;
    }
public function makeSql(bool $withLogicGroup = false): string
    {
        $sql = [
            'SELECT',
        ];

        foreach (array_keys($this->options) as $option) {
            if ('from' === $option) {
                $sql['from'] = '';
            } elseif ('union' === $option) {
                continue;
            } else {
                $method = 'parse'.ucfirst($option);

                if (method_exists($this, $method)) {
                    $sql[$option] = $this->{$method}();
                }
            }
        }

        $sql['from'] = $this->parseFrom();

        // 删除空元素
        foreach ($sql as $offset => $option) {
            if ('' === trim($option)) {
                unset($sql[$offset]);
            }
        }

        $sql[] = $this->parseUnion();

        $result = trim(implode(' ', $sql));

        if (true === $withLogicGroup) {
            return static::LOGIC_GROUP_LEFT.$result.static::LOGIC_GROUP_RIGHT;
        }

        return $result;
    }
获得查询字符串.

@param bool $withLogicGroup

@return string