public function formatTableName($params)
    {
        $params = trim($params);
        if (strpos($params, ',') !== false){
            $tables = explode(',', $params);
            foreach ($tables as $k=>$v) {
                $tables[$k] = $this->formatTableName($v);
            }
            $params = implode(',', $tables);
        } elseif (preg_match('/(\s(as\s)?)/i', $params, $matches)) { // 含空格或as分隔
            $arr = explode($matches[1], $params, 2);
            $params = $this->formatTableName($arr[0]) . $matches[1] . $arr[1];
            unset($arr, $matches);
        } else {
            $params = str_replace('#', '.', $params);
            $pos = strpos($params, '.');
            if ($pos === 0) {
                return ltrim($params, '.');
            } elseif ($pos === false && (isset($this->query['table_prefix'][0])|| isset($this->query['database'][0]))) {
                // 名称不含 . 且表前缀不为空 且名称不是前缀的 进行加库名加前缀处理
                $table_prefix = isset($this->query['table_prefix'][0]) ? $this->query['table_prefix'][0] : '';
                $database = isset($this->query['database'][0]) ? $this->query['database'][0] . '.' : '';
                if($table_prefix && !StringHelper::startsWith($params, $table_prefix, false)) {
                    $params = $this->formatKey($table_prefix . $params);
                }
                $params = $this->formatKey($database) . $params;
            }
        }
        return $params;
    }
public function formatTableName($params)
    {
        $params = trim($params);
        if (strpos($params, ',') !== false){
            $tables = explode(',', $params);
            foreach ($tables as $k=>$v) {
                $tables[$k] = $this->formatTableName($v);
            }
            $params = implode(',', $tables);
        } elseif (preg_match('/(\s(as\s)?)/i', $params, $matches)) { // 含空格或as分隔
            $arr = explode($matches[1], $params, 2);
            $params = $this->formatTableName($arr[0]) . $matches[1] . $arr[1];
            unset($arr, $matches);
        } else {
            $params = str_replace('#', '.', $params);
            $pos = strpos($params, '.');
            if ($pos === 0) {
                return ltrim($params, '.');
            } elseif ($pos === false && (isset($this->query['table_prefix'][0])|| isset($this->query['database'][0]))) {
                // 名称不含 . 且表前缀不为空 且名称不是前缀的 进行加库名加前缀处理
                $table_prefix = isset($this->query['table_prefix'][0]) ? $this->query['table_prefix'][0] : '';
                $database = isset($this->query['database'][0]) ? $this->query['database'][0] . '.' : '';
                if($table_prefix && !StringHelper::startsWith($params, $table_prefix, false)) {
                    $params = $this->formatKey($table_prefix . $params);
                }
                $params = $this->formatKey($database) . $params;
            }
        }
        return $params;
    }
public function formatTableName ( $ params ) { $ params = trim ( $ params ) ; if ( strpos ( $ params , ',' ) !== false ) { $ tables = explode ( ',' , $ params ) ; foreach ( $ tables as $ k => $ v ) { $ tables [ $ k ] = $ this -> formatTableName ( $ v ) ; } $ params = implode ( ',' , $ tables ) ; } elseif ( preg_match ( '/(\s(as\s)?)/i' , $ params , $ matches ) ) { // 含空格或as分隔 $ arr = explode ( $ matches [ 1 ] , $ params , 2 ) ; $ params = $ this -> formatTableName ( $ arr [ 0 ] ) . $ matches [ 1 ] . $ arr [ 1 ] ; unset ( $ arr , $ matches ) ; } else { $ params = str_replace ( '#' , '.' , $ params ) ; $ pos = strpos ( $ params , '.' ) ; if ( $ pos === 0 ) { return ltrim ( $ params , '.' ) ; } elseif ( $ pos === false && ( isset ( $ this -> query [ 'table_prefix' ] [ 0 ] ) || isset ( $ this -> query [ 'database' ] [ 0 ] ) ) ) { // 名称不含 . 且表前缀不为空 且名称不是前缀的 进行加库名加前缀处理 $ table_prefix = isset ( $ this -> query [ 'table_prefix' ] [ 0 ] ) ? $ this -> query [ 'table_prefix' ] [ 0 ] : '' ; $ database = isset ( $ this -> query [ 'database' ] [ 0 ] ) ? $ this -> query [ 'database' ] [ 0 ] . '.' : '' ; if ( $ table_prefix && ! StringHelper :: startsWith ( $ params , $ table_prefix , false ) ) { $ params = $ this -> formatKey ( $ table_prefix . $ params ) ; } $ params = $ this -> formatKey ( $ database ) . $ params ; } } return $ params ; }
format table, add dbname and table_prefix, instead of db
@param  string $params
@return string
format table add dbname and table_prefix instead of db