Schema::createTable

public Schema::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

\Drupal\Core\Database\SchemaObjectExistsException If the specified table already exists.

File

core/lib/Drupal/Core/Database/Schema.php, line 592

Class

Schema
Provides a base implementation for Database Schema.

Namespace

Drupal\Core\Database

Code

public function createTable($name, $table) {
  if ($this->tableExists($name)) {
    throw new SchemaObjectExistsException(t('Table @name already exists.', array('@name' => $name)));
  }
  $statements = $this->createTableSql($name, $table);
  foreach ($statements as $statement) {
    $this->connection->query($statement);
  }
}
doc_Drupal
2016-10-29 09:39:49
Comments
Leave a Comment

Please login to continue.