DatabaseSchema::createTable

7 schema.inc public DatabaseSchema::createTable($name, $table)

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.

File

includes/database/schema.inc, line 655
Generic Database schema code.

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);
  }
}
Login or register to post comments