| Versionen | |
|---|---|
| drupal6 – drupal7 | variable_set($name, $value) |
Sets a persistent variable.
Case-sensitivity of the variable_* functions depends on the database collation used. To avoid problems, always use lower case for persistent variable names.
$name The name of the variable to set.
$value The value to set. This can be any PHP data type; these functions take care of serialization as necessary.
variable_del(), variable_get()
includes/
<?php
function variable_set($name, $value) {
global $conf;
$serialized_value = serialize($value);
db_query("UPDATE {variable} SET value = '%s' WHERE name = '%s'", $serialized_value, $name);
if (!db_affected_rows()) {
@db_query("INSERT INTO {variable} (name, value) VALUES ('%s', '%s')", $name, $serialized_value);
}
cache_clear_all('variables', 'cache');
$conf[$name] = $value;
}
?>
Kommentare
Kommentar hinzufügen