You are here

public function DatabaseSchema_sqlsrv::queryColumnInformation in Drupal driver for SQL Server and SQL Azure 7

Same name and namespace in other branches
  1. 7.3 sqlsrv/schema.inc \DatabaseSchema_sqlsrv::queryColumnInformation()
  2. 7.2 sqlsrv/schema.inc \DatabaseSchema_sqlsrv::queryColumnInformation()

Database introspection: fetch technical information about a table.

File

sqlsrv/schema.inc, line 67
Database schema code for Microsoft SQL Server database servers.

Class

DatabaseSchema_sqlsrv

Code

public function queryColumnInformation($table) {
  $table_info = $this
    ->getPrefixInfo($table);
  $key = $table_info['schema'] . '.' . $table_info['table'];
  if (!isset($this->additionalColumnInformation[$key])) {
    $this->additionalColumnInformation[$key] = array();

    // Don't use {} around information_schema.columns table.
    $result = $this->connection
      ->query("SELECT name AS column_name FROM sys.columns WHERE object_id = OBJECT_ID(:table) AND user_type_id = TYPE_ID(:type)", array(
      ':table' => $table_info['schema'] . '.' . $table_info['table'],
      ':type' => 'varbinary',
    ));
    foreach ($result as $column) {
      $this->additionalColumnInformation[$key]['blobs'][$column->column_name] = TRUE;
    }

    // Don't use {} around system tables.
    $result = $this->connection
      ->query('SELECT name column_name FROM sys.identity_columns WHERE object_id = OBJECT_ID(:table)', array(
      ':table' => $table_info['schema'] . '.' . $table_info['table'],
    ));
    foreach ($result as $column) {
      $this->additionalColumnInformation[$key]['identities'][$column->column_name] = TRUE;
    }
  }
  return $this->additionalColumnInformation[$key];
}