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

Create a new table from a Backdrop table definition.

Parameters

string $name: The name of the table to create.

array $table: A Schema API table definition array.

Return value

void:

Throws

DatabaseSchemaObjectExistsException If the specified table already exists.

File

core/includes/database/schema.inc, line 682
Generic Database schema code.

Class

DatabaseSchema
Base class for database schema definitions.

Code

public function createTable($name, $table) { // phpcs:ignore -- No type hint on $table, add in 2.x.
  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);
  }
}