public function getTableInfo($table)
    {
        if (!$this->tableExists($table)) {
            return null;
        }
        
        $rtable = static::buildRealTableName($table, true);
        $key = 'db/tableinfo/' . $rtable;
        $data = static::getCache()->get($key);
        
        if (!$data) {
            $data = ['table_name' => $table];
            $data['fields'] = $this->getColumns($table);
            $pk = [];
            foreach ($data['fields'] as $key => $val) {
                if($val['is_primary']) {
                    $pk[] = $key;
                }
            }
            $data['primary_key'] = $pk ? $pk[0] : null;
            
            static::getCache()->set($key, $data);
        }
        
        return $data;
    }
public function getTableInfo($table)
    {
        if (!$this->tableExists($table)) {
            return null;
        }
        
        $rtable = static::buildRealTableName($table, true);
        $key = 'db/tableinfo/' . $rtable;
        $data = static::getCache()->get($key);
        
        if (!$data) {
            $data = ['table_name' => $table];
            $data['fields'] = $this->getColumns($table);
            $pk = [];
            foreach ($data['fields'] as $key => $val) {
                if($val['is_primary']) {
                    $pk[] = $key;
                }
            }
            $data['primary_key'] = $pk ? $pk[0] : null;
            
            static::getCache()->set($key, $data);
        }
        
        return $data;
    }
public function getTableInfo ( $ table ) { if ( ! $ this -> tableExists ( $ table ) ) { return null ; } $ rtable = static :: buildRealTableName ( $ table , true ) ; $ key = 'db/tableinfo/' . $ rtable ; $ data = static :: getCache ( ) -> get ( $ key ) ; if ( ! $ data ) { $ data = [ 'table_name' => $ table ] ; $ data [ 'fields' ] = $ this -> getColumns ( $ table ) ; $ pk = [ ] ; foreach ( $ data [ 'fields' ] as $ key => $ val ) { if ( $ val [ 'is_primary' ] ) { $ pk [ ] = $ key ; } } $ data [ 'primary_key' ] = $ pk ? $ pk [ 0 ] : null ; static :: getCache ( ) -> set ( $ key , $ data ) ; } return $ data ; }
get table info
@param  string $table
@return array|null  ['table_name'=>.., 'primary_key'=>'id', 'fields'=>[...]]
get table info