You are here

public function DataTable::drop in Data 7

Same name and namespace in other branches
  1. 6 includes/DataTable.inc \DataTable::drop()

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

Return value

TRUE if the table was dropped, FALSE otherwise.

File

includes/DataTable.inc, line 505
Contains class definition for DataTable.

Class

DataTable
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.

Code

public function drop() {
  if ($this->export_type == EXPORT_IN_DATABASE) {
    if (db_table_exists($this->name)) {
      db_drop_table($this->name);
    }
    $this
      ->update(array(
      'table_schema' => array(),
    ));
    drupal_get_schema($this->name, TRUE);
    db_delete('data_tables')
      ->condition('name', $this->name)
      ->execute();
    $this->title = '';
    $this->table_schema = $this->meta = array();
    return TRUE;
  }
  return FALSE;
}