src/db/BuildSql.php
public function bulidSql($type = 'SELECT')
    {
        $this->options['type'] = $type;

        if (!$this->bulid['table']) {
            throw new Exception('请选择数据表');
        }

        if ($type == 'SELECT') {
            $this->bulid['sql'] = 'SELECT ' . $this->bulid['field'] . ' FROM ' . $this->bulid['table'];
        } elseif ($type == 'UPDATE') {
            $this->bulid['sql'] = 'UPDATE ' . $this->bulid['table'] . ' SET ' . $this->bulid['data'];
        } elseif ($type == 'INSERT') {
            $this->bulid['sql'] = 'INSERT INTO ' . $this->bulid['table'] . ' SET ' . $this->bulid['data'];
        } elseif ($type == 'DELETE') {
            $this->bulid['sql'] = 'DELETE FROM ' . $this->bulid['table'];
        } elseif ($type == 'COUNT') {
            $this->bulid['sql'] = 'SELECT  COUNT(' . $this->bulid['field'] . ') AS  t  FROM ' . $this->bulid['table'];
        }

        empty($this->bulid['join']) ?: $this->bulid['sql'] .= $this->bulid['join'];
        empty($this->bulid['where']) ?: $this->bulid['sql'] .= $this->bulid['where'];
        empty($this->bulid['group']) ?: $this->bulid['sql'] .= $this->bulid['group'];
        empty($this->bulid['having']) ?: $this->bulid['sql'] .= $this->bulid['having'];
        empty($this->bulid['order']) ?: $this->bulid['sql'] .= $this->bulid['order'];
        empty($this->bulid['limit']) ?: $this->bulid['sql'] .= $this->bulid['limit'];

    }
public function bulidSql($type = 'SELECT')
    {
        $this->options['type'] = $type;

        if (!$this->bulid['table']) {
            throw new Exception('请选择数据表');
        }

        if ($type == 'SELECT') {
            $this->bulid['sql'] = 'SELECT ' . $this->bulid['field'] . ' FROM ' . $this->bulid['table'];
        } elseif ($type == 'UPDATE') {
            $this->bulid['sql'] = 'UPDATE ' . $this->bulid['table'] . ' SET ' . $this->bulid['data'];
        } elseif ($type == 'INSERT') {
            $this->bulid['sql'] = 'INSERT INTO ' . $this->bulid['table'] . ' SET ' . $this->bulid['data'];
        } elseif ($type == 'DELETE') {
            $this->bulid['sql'] = 'DELETE FROM ' . $this->bulid['table'];
        } elseif ($type == 'COUNT') {
            $this->bulid['sql'] = 'SELECT  COUNT(' . $this->bulid['field'] . ') AS  t  FROM ' . $this->bulid['table'];
        }

        empty($this->bulid['join']) ?: $this->bulid['sql'] .= $this->bulid['join'];
        empty($this->bulid['where']) ?: $this->bulid['sql'] .= $this->bulid['where'];
        empty($this->bulid['group']) ?: $this->bulid['sql'] .= $this->bulid['group'];
        empty($this->bulid['having']) ?: $this->bulid['sql'] .= $this->bulid['having'];
        empty($this->bulid['order']) ?: $this->bulid['sql'] .= $this->bulid['order'];
        empty($this->bulid['limit']) ?: $this->bulid['sql'] .= $this->bulid['limit'];

    }
构建SQL语句