[development] Removing variables

Peter Anderson list at panda.id.au
Thu May 26 22:58:57 UTC 2011

Hi all,

I have a module that uses quite a few variables and would like to remove 
them in my hook_uninstall() function, but I don't want to have to list 
them all manually...

I see three ways to do this:
1 - Run variable_del() for each variable manually
2 - List all variables then remove the ones that start with my module's name
3 - Delete variables directly from the database that start with my 
module's name

I'm obviously trying to avoid #1.
I've used #2 before (http://drupalbin.com/18718) but am worried about 
the possible performance implications of running a foreach() on every 
variable in Drupal... Is this good or not?
I'd prefer not to resort to using SQL to delete variables from the 
database directly as in #3, but this may be the only recommended option...

What is the recommended way to call variable_del() on a bunch of 
variables? I'm using D7 if that helps.

Kind regards,
Peter Anderson.

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.drupal.org/pipermail/development/attachments/20110527/dce4a49d/attachment.html 

More information about the development mailing list