function view::delete

3.x view.inc view::delete($clear = TRUE)
2.x view.inc view::delete($clear = TRUE)

Delete the view from the database.

File

includes/view.inc, line 1869
Provides the view object type and associated methods.

Class

view
An object to contain all of the data to generate a view, plus the member functions to build the view query, execute the query and render the output.

Code

function delete($clear = TRUE) {
  if (empty($this->vid)) {
    return;
  }

  db_delete('views_view')
    ->condition('vid', $this->vid)
    ->execute();
  // Delete from all of our subtables as well.
  foreach ($this->db_objects() as $key) {
    db_delete('views_' . $key)
      ->condition('vid', $this->vid)
      ->execute();
  }

  cache_clear_all('views_query:' . $this->name, 'cache_views');

  if ($clear) {
    // Clear caches.
    views_invalidate_cache();
  }
}