Cml\Db\MySql\Pdo::buildSql PHP Method

buildSql() public method

构建sql
public buildSql ( null $offset = null, null $limit = null, boolean $isSelect = false ) : string | array
$offset null 偏移量
$limit null 返回的条数
$isSelect boolean 是否为select调用, 是则不重置查询参数并返回cacheKey/否则直接返回sql并重置查询参数
return string | array
    public function buildSql($offset = null, $limit = null, $isSelect = false)
    {
        is_null($offset) || $this->limit($offset, $limit);
        $this->sql['columns'] == '' && ($this->sql['columns'] = '*');
        $columns = $this->sql['columns'];
        $tableAndCacheKey = $this->tableFactory();
        empty($this->sql['limit']) && ($this->sql['limit'] = "LIMIT 0, 100");
        $sql = "SELECT {$columns} FROM {$tableAndCacheKey[0]} " . $this->sql['where'] . $this->sql['groupBy'] . $this->sql['having'] . $this->sql['orderBy'] . $this->union . $this->sql['limit'];
        if ($isSelect) {
            return [$sql, $tableAndCacheKey[1]];
        } else {
            $this->currentSql = $sql;
            $sql = $this->buildDebugSql();
            $this->reset();
            $this->clearBindParams();
            $this->currentSql = '';
            return " ({$sql}) ";
        }
    }