src/Leevel/Database/Condition.php
protected function addCols(string $tableName, $cols): void
    {
        // 处理条件表达式
        if (is_string($cols) &&
            false !== strpos($cols, ',') &&
            false !== strpos($cols, '{') &&
            preg_match_all('/{(.+?)}/', $cols, $matches)) {
            $cols = str_replace(
                $matches[1][0],
                base64_encode($matches[1][0]),
                $cols
            );
        }

        $cols = normalize($cols);

        // 还原
        if (!empty($matches)) {
            foreach ($matches[1] as $tmp) {
                $key = array_search('{'.base64_encode($tmp).'}', $cols, true);
                $cols[$key] = '{'.$tmp.'}';
            }
        }

        // 没有字段则退出
        if (empty($cols)) {
            return;
        }

        foreach ($cols as $alias => $col) {
            // 处理条件表达式
            if (false !== strpos($col, ',') &&
                false !== strpos($col, '{') &&
                preg_match_all('/{(.+?)}/', $col, $subMatches)) {
                $col = str_replace(
                    $subMatches[1][0],
                    base64_encode($subMatches[1][0]),
                    $col
                );
            }

            $col = normalize($col);

            // 还原
            if (!empty($subMatches)) {
                foreach ($subMatches[1] as $tmp) {
                    $key = array_search('{'.base64_encode($tmp).'}', $col, true);
                    $col[$key] = '{'.$tmp.'}';
                }
            }

            // 将包含多个字段的字符串打散
            foreach (normalize($col) as $col) {
                $currentTableName = $tableName;

                // 检查是不是 "字段名 AS 别名"这样的形式
                if (preg_match('/^(.+)\s+'.'AS'.'\s+(.+)$/i', $col, $matches)) {
                    $col = $matches[1];
                    $alias = $matches[2];
                }

                // 检查字段名是否包含表名称
                if (preg_match('/(.+)\.(.+)/', $col, $matches)) {
                    $currentTableName = $matches[1];
                    $col = $matches[2];
                }

                $this->options['columns'][] = [
                    $currentTableName,
                    $col,
                    is_string($alias) ? $alias : null,
                ];
            }
        }
    }
protected function addCols(string $tableName, $cols): void
    {
        // 处理条件表达式
        if (is_string($cols) &&
            false !== strpos($cols, ',') &&
            false !== strpos($cols, '{') &&
            preg_match_all('/{(.+?)}/', $cols, $matches)) {
            $cols = str_replace(
                $matches[1][0],
                base64_encode($matches[1][0]),
                $cols
            );
        }

        $cols = normalize($cols);

        // 还原
        if (!empty($matches)) {
            foreach ($matches[1] as $tmp) {
                $key = array_search('{'.base64_encode($tmp).'}', $cols, true);
                $cols[$key] = '{'.$tmp.'}';
            }
        }

        // 没有字段则退出
        if (empty($cols)) {
            return;
        }

        foreach ($cols as $alias => $col) {
            // 处理条件表达式
            if (false !== strpos($col, ',') &&
                false !== strpos($col, '{') &&
                preg_match_all('/{(.+?)}/', $col, $subMatches)) {
                $col = str_replace(
                    $subMatches[1][0],
                    base64_encode($subMatches[1][0]),
                    $col
                );
            }

            $col = normalize($col);

            // 还原
            if (!empty($subMatches)) {
                foreach ($subMatches[1] as $tmp) {
                    $key = array_search('{'.base64_encode($tmp).'}', $col, true);
                    $col[$key] = '{'.$tmp.'}';
                }
            }

            // 将包含多个字段的字符串打散
            foreach (normalize($col) as $col) {
                $currentTableName = $tableName;

                // 检查是不是 "字段名 AS 别名"这样的形式
                if (preg_match('/^(.+)\s+'.'AS'.'\s+(.+)$/i', $col, $matches)) {
                    $col = $matches[1];
                    $alias = $matches[2];
                }

                // 检查字段名是否包含表名称
                if (preg_match('/(.+)\.(.+)/', $col, $matches)) {
                    $currentTableName = $matches[1];
                    $col = $matches[2];
                }

                $this->options['columns'][] = [
                    $currentTableName,
                    $col,
                    is_string($alias) ? $alias : null,
                ];
            }
        }
    }
添加字段.

@param string $tableName
@param mixed  $cols