Last active
August 29, 2015 14:18
-
-
Save slivorezka/394e45941847e3fca75a to your computer and use it in GitHub Desktop.
Implements hook_uninstall()
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Implements hook_uninstall(). | |
*/ | |
function drupal_way_test_uninstall() { | |
// Remove the all module tables. | |
drupal_uninstall_schema('drupal_way_test'); | |
// Remove the all module variables. | |
// variable_del('drupal_way_test_...'); | |
// variable_del('drupal_way_test_...'); | |
// variable_del('...'); | |
// Or. | |
$variables = db_select('variable', 'v') | |
->fields('v', array('name')) | |
->condition('v.name', db_like('drupal_way_test_') . '%', 'LIKE') | |
->execute() | |
->fetchAllAssoc('name'); | |
if (!empty($variables)) { | |
global $conf; | |
$variables = array_keys($variables); | |
foreach ($variables as $variable_name) { | |
db_delete('variable') | |
->condition('name', $variable_name) | |
->execute(); | |
unset($conf[$variable_name]); | |
} | |
// Variable cache clear. | |
cache_clear_all('variables', 'cache_bootstrap'); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment