function DatabaseSchema::createTable

Create a new table from a Drupal table definition.

Parameters

$name: The name of the table to create.

$table: A Schema API table definition array.

Throws

DatabaseSchemaObjectExistsException If the specified table already exists.

1 call to DatabaseSchema::createTable()
DatabaseSchema_sqlite::alterTable in includes/database/sqlite/schema.inc
Create a table with a new schema containing the old content.

File

includes/database/schema.inc, line 729

Class

DatabaseSchema
Base class for database schema definitions.

Code

public function createTable($name, $table) {
  if ($this->tableExists($name)) {
    throw new DatabaseSchemaObjectExistsException(t('Table @name already exists.', array(
      '@name' => $name,
    )));
  }
  $statements = $this->createTableSql($name, $table);
  foreach ($statements as $statement) {
    $this->connection
      ->query($statement);
  }
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.