You are here

public static function Vars::deleteVariables in Variable API 7

Same name and namespace in other branches
  1. 6.2 vars.module \Vars::deleteVariables()
  2. 6 vars.module \Vars::deleteVariables()
  3. 7.2 vars.classes.inc \Vars::deleteVariables()

Deletes the specified persistent variables.

Deletes the specified persistent variables from memory, and from the database.

Parameters

$names: An array of persistent variable names.

See also

Vars::renameVariables()

2 calls to Vars::deleteVariables()
Vars::offsetUnset in ./vars.module
Implements ArrayAccess::offsetUnset().
VarsExtendedTestCase::testDeletingVars in tests/vars.test

File

./vars.module, line 63
Implement an API to handle persistent variables.

Class

Vars
@file Implement an API to handle persistent variables.

Code

public static function deleteVariables(array $names) {
  global $conf;
  $count = 0;
  foreach ($names as $name) {
    unset($conf[$name]);
    $count++;
  }
  if ($count) {
    db_delete('variable')
      ->condition('name', $names, 'IN')
      ->execute();
    cache_clear_all('variables', 'cache_bootstrap');
  }
}