src/PDO/SchemaPDOMssql.php
/**
     * Collects the constraint details for the given table and constraint type.
     *
     * @param TableSchema $table
     * @param string $type either PRIMARY KEY or UNIQUE.
     *
     * @throws Exception|InvalidConfigException|Throwable
     *
     * @return array each entry contains index_name and field_name.
     */
Collects the constraint details for the given table and constraint type.
@param TableSchema $table
@param string $type either PRIMARY KEY or UNIQUE.



@return array each entry contains index_name and field_name.
Collects the constraint details for the given table and constraint type . @param TableSchema $table @param string $type either PRIMARY KEY or UNIQUE . @return array each entry contains index_name and field_name .
protected function findTableConstraints(TableSchema $table, string $type): array
    {
        $keyColumnUsageTableName = 'INFORMATION_SCHEMA.KEY_COLUMN_USAGE';
        $tableConstraintsTableName = 'INFORMATION_SCHEMA.TABLE_CONSTRAINTS';
        if ($table->getCatalogName() !== null) {
            $keyColumnUsageTableName = $table->getCatalogName() . '.' . $keyColumnUsageTableName;
            $tableConstraintsTableName = $table->getCatalogName() . '.' . $tableConstraintsTableName;
        }
        $keyColumnUsageTableName = $this->db->getQuoter()->quoteTableName($keyColumnUsageTableName);
        $tableConstraintsTableName = $this->db->getQuoter()->quoteTableName($tableConstraintsTableName);
        $sql = <<<SQL
        SELECT
            [kcu].[constraint_name] AS [index_name],
            [kcu].[column_name] AS [field_name]
        FROM $keyColumnUsageTableName AS [kcu]
        LEFT JOIN $tableConstraintsTableName AS [tc] ON
            [kcu].[table_schema] = [tc].[table_schema] AND
            [kcu].[table_name] = [tc].[table_name] AND
            [kcu].[constraint_name] = [tc].[constraint_name]
        WHERE
            [tc].[constraint_type] = :type AND
            [kcu].[table_name] = :tableName AND
            [kcu].[table_schema] = :schemaName
        SQL;
        return $this->db->createCommand(
            $sql,
            [
                ':tableName' => $table->getName(),
                ':schemaName' => $table->getSchemaName(),
                ':type' => $type,
            ]
        )->queryAll();
    }
protected function findTableConstraints ( TableSchema $ table , string $ type ) : array { $ keyColumnUsageTableName = 'INFORMATION_SCHEMA.KEY_COLUMN_USAGE' ; $ tableConstraintsTableName = 'INFORMATION_SCHEMA.TABLE_CONSTRAINTS' ; if ( $ table -> getCatalogName ( ) !== null ) { $ keyColumnUsageTableName = $ table -> getCatalogName ( ) . '.' . $ keyColumnUsageTableName ; $ tableConstraintsTableName = $ table -> getCatalogName ( ) . '.' . $ tableConstraintsTableName ; } $ keyColumnUsageTableName = $ this -> db -> getQuoter ( ) -> quoteTableName ( $ keyColumnUsageTableName ) ; $ tableConstraintsTableName = $ this -> db -> getQuoter ( ) -> quoteTableName ( $ tableConstraintsTableName ) ; $ sql = <<< SQL         SELECT             [kcu].[constraint_name] AS [index_name],             [kcu].[column_name] AS [field_name]         FROM  $ keyColumnUsageTableName  AS [kcu]         LEFT JOIN  $ tableConstraintsTableName  AS [tc] ON             [kcu].[table_schema] = [tc].[table_schema] AND             [kcu].[table_name] = [tc].[table_name] AND             [kcu].[constraint_name] = [tc].[constraint_name]         WHERE             [tc].[constraint_type] = :type AND             [kcu].[table_name] = :tableName AND             [kcu].[table_schema] = :schemaName 
        SQL ; return $ this -> db -> createCommand ( $ sql , [ ':tableName' => $ table -> getName ( ) , ':schemaName' => $ table -> getSchemaName ( ) , ':type' => $ type , ] ) -> queryAll ( ) ; }
Collects the constraint details for the given table and constraint type.
Collects the constraint details for the given table and constraint type .