You are here

public function DatabaseSchema_sqlsrv::getDatabaseInfo in Drupal driver for SQL Server and SQL Azure 7.2

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

Get database information from sys.databases

Return value

mixed

File

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

Class

DatabaseSchema_sqlsrv

Code

public function getDatabaseInfo() {
  if ($cache = fastcache::cache_get('getDatabaseInfo', 'schema')) {
    return $cache->data;
  }
  $sql = <<<EOF
      select name
        , db.snapshot_isolation_state
        , db.snapshot_isolation_state_desc
        , db.is_read_committed_snapshot_on
        , db.recovery_model
        , db.recovery_model_desc
        , db.collation_name
    from sys.databases db
    WHERE DB_NAME(db.database_id) = :database
EOF;

  // Database is defaulted from active connection.
  $options = $this->connection
    ->getConnectionOptions();
  $database = $options['database'];
  $result = $this->connection
    ->query_direct($sql, array(
    ':database' => $database,
  ))
    ->fetchObject();
  fastcache::cache_set('getDatabaseInfo', $result, 'schema');
  return $result;
}