function update_variable_set

Sets a persistent variable during the 7.x-8.x upgrade path.

Use this during the 7.x-8.x upgrade path instead of variable_set().

Parameters

string $name: The name of the variable to set.

mixed $value: The value to set. This can be any PHP data type; these functions take care of serialization as necessary.

See also

update_variable_get()

update_variable_del()

Related topics

11 calls to update_variable_set()
field_update_8004 in drupal/core/modules/field/field.install
Moves field_storage_default and field_language_fallback to config.
locale_update_8001 in drupal/core/modules/locale/locale.install
Language type 'language' renamed to 'language_interface'.
locale_update_8004 in drupal/core/modules/locale/locale.install
Rename language providers to language negotiation methods.
locale_update_8007 in drupal/core/modules/locale/locale.install
Convert language_negotiation_* variables to use the new callbacks.
locale_update_8013 in drupal/core/modules/locale/locale.install
Renames language_default language negotiation method to language_selected.

... See full list

File

drupal/core/includes/update.inc, line 1321
Drupal database update API.

Code

function update_variable_set($name, $value) {
  db_merge('variable')
    ->key(array(
    'name' => $name,
  ))
    ->fields(array(
    'value' => serialize($value),
  ))
    ->execute();
}