This would be in an install file in a module. The purpose is to create setting for a module that is already installed (the module is node_revision_delete). I know how to use variable_set to change a value in the variable table but not when it is longblob. Do I just use the variables from the module? Do you know of any examples I could look at?
1 Answer
With variable_set() you can set a persistent variable to any PHP value, including array. variable_set() will serialize the value passed as second argument, and variable_get() will unserialize that value. If you pass an array to variable_set() for a persistent variable, variable_get() will return an array for the same persistent variable (if another module doesn't change that persistent variable's value to an integer, for example).
Suppose that you want to change the value of node_revision_delete_minimum_age_to_delete_time, which is set from that module in its installation hook using the following code.
$node_revision_delete_minimum_age_to_delete_time = array( 'max_number' => 12, 'time' => 'months', ); variable_set('node_revision_delete_minimum_age_to_delete_time', $node_revision_delete_minimum_age_to_delete_time); If you want to change max_number to 24, you would use code similar to the following one.
$node_revision_delete_minimum_age_to_delete_time = variable_get('node_revision_delete_minimum_age_to_delete_time', array()); if (is_array($node_revision_delete_minimum_age_to_delete_time)) { $node_revision_delete_minimum_age_to_delete_time['max_number'] = 24; variable_set('node_revision_delete_minimum_age_to_delete_time', $node_revision_delete_minimum_age_to_delete_time); }
variabletable. Are you asking how to set a complex value (as opposed to an int or string)?