function view::save
Same name in other branches
- 7.x-3.x includes/view.inc \view::save()
Save the view to the database. If the view does not already exist, A vid will be assigned to the view and also returned from this function.
File
-
includes/
view.inc, line 1670
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 save() {
if ($this->vid == 'new') {
$this->vid = NULL;
}
// If we have no vid or our vid is a string, this is a new view.
if (!empty($this->vid)) {
// remove existing table entries
foreach ($this->db_objects() as $key) {
db_query("DELETE from {views_" . $key . "} WHERE vid = %d", $this->vid);
}
}
$this->save_row(!empty($this->vid) ? 'vid' : FALSE);
// Save all of our subtables.
foreach ($this->db_objects() as $key) {
$this->_save_rows($key);
}
$this->save_locale_strings();
cache_clear_all('views_urls', 'cache_views');
cache_clear_all();
// clear the page cache as well.
}