<html><head></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; ">Hi,<div><br></div><div>you should use the standard interfaces esp in Drupal as there are so many hooks that can be triggered from seemingly harmless function calls.</div><div><br></div><div>Besides that this is an uninstall function and hardly every gets run so who cares how bad it is. </div><div><br></div><div>Also on a lesser note, in Drupal 8 everything is going to be pluggable, so doing things in ways other than using the standard interfaces will be a bad thing, and it is good to get into practice now.</div><div><br></div><div>Gordon.</div><div><br><div><div>On 27/05/2011, at 8:58 AM, Peter Anderson wrote:</div><br class="Apple-interchange-newline"><blockquote type="cite">
<div bgcolor="#ffffff" text="#000000">
<font face="sans-serif">Hi all,<br>
<br>
I have a module that uses quite a few variables</font> and would
like to remove them in my hook_uninstall() function, but I don't
want to have to list them all manually...<br>
<br>
I see three ways to do this:<br>
1 - Run variable_del() for each variable manually<br>
2 - List all variables then remove the ones that start with my
module's name<br>
3 - Delete variables directly from the database that start with my
module's name<br>
<br>
I'm obviously trying to avoid #1.<br>
I've used #2 before (<a class="moz-txt-link-freetext" href="http://drupalbin.com/18718">http://drupalbin.com/18718</a>) but am worried
about the possible performance implications of running a foreach()
on every variable in Drupal... Is this good or not?<br>
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...<br>
<br>
What is the recommended way to call variable_del() on a bunch of
variables? I'm using D7 if that helps.<br>
Thanks.<br>
<br>
<pre class="moz-signature" cols="72">--
Kind regards,
Peter Anderson.
<a class="moz-txt-link-freetext" href="http://panda.id.au/">http://panda.id.au</a>
</pre>
</div>
</blockquote></div><br></div></body></html>