You are here

function variable_store_set in Variable 7.2

Same name and namespace in other branches
  1. 7 variable_store/variable_store.module \variable_store_set()

Set variable value

2 calls to variable_store_set()
VariableStoreRealmStore::variable_set in variable_store/variable_store.class.inc
Set single variable.
VariableStoreTestCase::testVariableStoreAPI in variable_store/variable_store.test
Test that all core modules can be enabled, disabled and uninstalled.

File

variable_store/variable_store.module, line 138
Variable API module - Database storage

Code

function variable_store_set($realm, $key, $name, $value, $rebuild = TRUE) {
  $store =& variable_store($realm, $key);
  $serialize = !is_int($value) && !is_string($value);
  db_merge('variable_store')
    ->key(array(
    'realm' => $realm,
    'realm_key' => $key,
    'name' => $name,
  ))
    ->fields(array(
    'value' => $serialize ? serialize($value) : $value,
    'serialized' => $serialize ? 1 : 0,
  ))
    ->execute();
  cache_clear_all('variable:' . $realm . ':' . $key, 'cache_bootstrap');
  $store[$name] = $value;
}