Prado\Data\Common\Mssql\TMssqlMetaData::createTableInfo PHP Method

createTableInfo() protected method

Get the column definitions for given table.
protected createTableInfo ( $table ) : TMssqlTableInfo
return TMssqlTableInfo table information.
    protected function createTableInfo($table)
    {
        list($catalogName, $schemaName, $tableName) = $this->getCatalogSchemaTableName($table);
        $this->getDbConnection()->setActive(true);
        $sql = <<<EOD
\t\t\t\tSELECT t.*,
\t\t\t\t\t\t\t\t\t\t\t\tc.*,
\t\t\t\t\tcolumnproperty(object_id(c.table_schema + '.' + c.table_name), c.column_name,'IsIdentity') as IsIdentity
\t\t\t\t\t\t\t\t\t\tFROM INFORMATION_SCHEMA.TABLES t,
\t\t\t\t\t\t\t\t\t\t\t\tINFORMATION_SCHEMA.COLUMNS c
\t\t\t\t\t\t\t\t\tWHERE t.table_name = c.table_name
\t\t\t\t\t\t\t\t\t\tAND t.table_name = :table
EOD;
        if ($schemaName !== null) {
            $sql .= ' AND t.table_schema = :schema';
        }
        if ($catalogName !== null) {
            $sql .= ' AND t.table_catalog = :catalog';
        }
        $command = $this->getDbConnection()->createCommand($sql);
        $command->bindValue(':table', $tableName);
        if ($schemaName !== null) {
            $command->bindValue(':schema', $schemaName);
        }
        if ($catalogName !== null) {
            $command->bindValue(':catalog', $catalogName);
        }
        $tableInfo = null;
        foreach ($command->query() as $col) {
            if ($tableInfo === null) {
                $tableInfo = $this->createNewTableInfo($col);
            }
            $this->processColumn($tableInfo, $col);
        }
        if ($tableInfo === null) {
            throw new TDbException('dbmetadata_invalid_table_view', $table);
        }
        return $tableInfo;
    }