How can i update a table during the installation of a module in drupal 7? i used the following code . But it is not working
function mymodule_install() {
drupal_install_schema('template_config');
db_update('system')
->fields(array(
'status' => 1,
))
->condtion('type','theme','=')
->execute();
}
What is wrong in this code. i want to enable all the themes on the time of installation of mymodule.
You shouldn’t call
drupal_install_schema()from ahook_install()in Drupal 7, the schema will automatically be installed when the module is. Other than that your code will definitely work but I think you’ll need to clear the caches straight after. Your install function should probably look like this:Also make sure you’re actually uninstalling and reinstalling your module, not just disabling it and then re-enabling it (click the ‘Uninstall’ tab from the modules page when you’ve disabled the module).