You are here

public function Table::drop in Data 8

Drop a table. Does not drop a table if its defined in code.

Return value

TRUE if the table was dropped, FALSE otherwise.

File

src/Table.php, line 503

Class

Table
Manages data access and manipulation for a single data table. Use data_create_table() or data_get_table() to instantiate an object from this class.

Namespace

Drupal\data

Code

public function drop() {
  if ($this->export_type == EXPORT_IN_DATABASE) {
    if (\Drupal::database()
      ->schema()
      ->tableExists($this->name)) {
      \Drupal::database()
        ->schema()
        ->dropTable($this->name);
    }
    $this
      ->update(array(
      'table_schema' => array(),
    ));
    drupal_get_schema($this->name, TRUE);
    \Drupal::database()
      ->delete('data_tables')
      ->condition('name', $this->name)
      ->execute();
    $this->title = '';
    $this->table_schema = $this->meta = array();
    return TRUE;
  }
  return FALSE;
}