get table schema instance

@param   string  $table
@param   string  $database
@return  Samurai\Onikiri\Schema\TableSchema
175726
public function getTableSchema($table, $database = 'base')
    {
        $cacher = $this->config->getSchemaCacher();
        if ($cacher->has($table)) return $cacher->get($table);

        $driver = $this->getDatabase($database)->getDriver();
        $connection = $this->establishConnection($database, Database::TARGET_SLAVE);
        $describe = $driver->getTableDescribe($connection, $table);

        $schema = new TableSchema($table, $describe);
        $cacher->cache($table, $schema);
        return $schema;
    }
839035
public function getTables($database=null)
    {
        if (empty($database)) $database = $this->getDatabase();
        
        $key  = 'db/tables/' . $database;
        $data = static::getCache()->get($key);
        if (!$data) {
            $data = $this->getAdapter()->getTables($database);
            static::getCache()->set($key, $data);
        }
        return $data;
    }
577126
protected static function getCreateTableSql($table)
    {
        $db = Yii::$app->db;
        $row = $db->createCommand('SHOW CREATE TABLE ' . $db->schema->quoteTableName($table->fullName))->queryOne();
        if (isset($row['Create Table'])) {
            $sql = $row['Create Table'];
        } else {
            $row = array_values($row);
            $sql = $row[1];
        }

        return $sql;
    }
685250
public function from($table, ...$tables)
    {
        $instance = $this->fromStrategyInstance();

        $instance->fromStrategy()->from($table, ...$tables);

        return $instance;
    }
1304137
function GetSchema()
	{
		$this->Connection->Connect();
		
		$schema = new DBSchema($this);
		
		$this->Connection->Disconnect();
		
		return $schema;
	}
328781
public function from(string $table, string $alias = null, string $database = null)
    {
        return $this->table($table, $alias, $database);
    }
379982
protected function _generateMetaColumnsSQL($table, $schema)
	{
		if ($schema) {
			return sprintf($this->metaColumnsSQL1, $table, $table, $table, $schema);
		}
		else {
			return sprintf($this->metaColumnsSQL, $table, $table, $schema);
		}
	}
1022514
protected function getTable()
    {
        $schema = $this->connection->getSchemaManager();

        if (!$schema->tablesExist($this->table)) {
            $schema->createTable($this->getTableDefinition());
        }

        return $this->getConnection()->createQueryBuilder();
    }
671193
public function getTableColumns(string $table): array {
		$query = <<<QUERY
			SELECT COLUMN_NAME
			FROM INFORMATION_SCHEMA.COLUMNS
			WHERE TABLE_SCHEMA = :database
			AND TABLE_NAME = :table
QUERY;
		
		$params = [
			"database" => $this->database,
			"table"    => $table,
		];
		
		try {
			$results = $this->getCol($query, $params);
			return is_array($results) ? $results : [];
		} catch (\PDOException $databaseException) {
			throw $this->prepareDatabaseException($databaseException, $query, $params);
		}
	}
1177623
public function getTableSchema($table)
    {
        if (!isset($this->_table_schema[$table])) {
            $this->_table_schema[$table] = $this->_fetchTableInfo($table);
            $this->_table_schema[$table]->indexes = $this->_fetchTableIndexes($table);
            $this->_table_schema[$table]->columns = $this->_fetchTableColumns($table);
        }

        return $this->_table_schema[$table];
    }
252197
public function getTable($table)
    {
        return array_merge(
            $this->cache['tables'][$table],
            [
                'fields'      => $this->cache['fields'][$table] ?? [],
                'constraints' => $this->cache['constraints'][$table] ?? [],
            ]
        );
    }
309667
public function listTableForeignKeys($table, $database = null)
    {
        if ($database === null) {
            $database = $this->_conn->getDatabase();
        }
        $sql              = $this->_platform->getListTableForeignKeysSQL($table, $database);
        $tableForeignKeys = $this->_conn->fetchAll($sql);

        return $this->_getPortableTableForeignKeysList($tableForeignKeys);
    }
1021543
protected function _fetchTableInfo($table)
    {
        $result = null;
        $sql    = $this->quoteValue($this->getTableNeedle().$table);

        if ($info  = $this->show('SHOW TABLE STATUS LIKE '.$sql, AnDatabase::FETCH_OBJECT)) {
            //Parse the table raw schema data
            $result = $this->_parseTableInfo($info);
        }

        return $result;
    }
325391
public function initialize($schema, $table=null)
    {
        $mapper = $this->_mapper($schema);
        $table = $table ? $this->_connection($schema)->table($table) : $mapper->table();

        $sequencePool = $this->_connection($schema)->sequencePool();
        $sequencePool->initialize();

        $columns = array();

        // build a map of properties to create
        foreach ($schema->properties() as $prop) {
            $columns[$prop->name] = $prop->type;

            // reset sequences as we go
            if (property_exists($prop->type, 'sequence')) {
                $sequencePool->delete($mapper->sequenceName($prop));
            }
        }

        $table->create($columns);

        return $this;
    }
675133
public function getTable($tableName)
    {
        $tableName = $this->getFullQualifiedAssetName($tableName);
        if (! isset($this->_tables[$tableName])) {
            throw SchemaException::tableDoesNotExist($tableName);
        }

        return $this->_tables[$tableName];
    }
333681
public function table($table, /*# string */ $alias = '')
    {
        $tbl = $this->fixTable($table, $alias);
        $clone = [] === $this->tables ? $this : clone $this;
        $clone->tables = $tbl;
        return $clone;
    }
1358264
protected function findColumns($table)
	{
		$schemaName=$table->schemaName;
		$tableName=$table->name;

		$sql=<<<EOD
SELECT a.column_name, a.data_type ||
    case
        when data_precision is not null
            then '(' || a.data_precision ||
                    case when a.data_scale > 0 then ',' || a.data_scale else '' end
                || ')'
        when data_type = 'DATE' then ''
        when data_type = 'NUMBER' then ''
        else '(' || to_char(a.data_length) || ')'
    end as data_type,
    a.nullable, a.data_default,
    (   SELECT D.constraint_type
        FROM ALL_CONS_COLUMNS C
        inner join ALL_constraints D on D.OWNER = C.OWNER and D.constraint_name = C.constraint_name
        WHERE C.OWNER = B.OWNER
           and C.table_name = B.object_name
           and C.column_name = A.column_name
           and D.constraint_type = 'P') as Key,
    com.comments as column_comment
FROM ALL_TAB_COLUMNS A
inner join ALL_OBJECTS B ON b.owner = a.owner and ltrim(B.OBJECT_NAME) = ltrim(A.TABLE_NAME)
LEFT JOIN all_col_comments com ON (A.owner = com.owner AND A.table_name = com.table_name AND A.column_name = com.column_name)
WHERE
    a.owner = '{$schemaName}'
	and (b.object_type = 'TABLE' or b.object_type = 'VIEW')
	and b.object_name = '{$tableName}'
ORDER by a.column_id
EOD;

		$command=$this->getDbConnection()->createCommand($sql);

		if(($columns=$command->queryAll())===array()){
			return false;
		}

		foreach($columns as $column)
		{
			$c=$this->createColumn($column);

			$table->columns[$c->name]=$c;
			if($c->isPrimaryKey)
			{
				if($table->primaryKey===null)
					$table->primaryKey=$c->name;
				elseif(is_string($table->primaryKey))
					$table->primaryKey=array($table->primaryKey,$c->name);
				else
					$table->primaryKey[]=$c->name;
				$table->sequenceName='';
				$c->autoIncrement=true;
			}
		}
		return true;
	}