Can a Drupal7 Module Use hook_update_n Instead of hook_install?

Recently I was asked if a module could use hook_update_n and not need to implement hook_install. The developer wanted to alter existing SQL tables accessible by Drupal using the Drupal database API.

Drupal Hooks allow your module(s) and theme(s) to interact with the Drupal system. There is essentially no requirement that X hooks must be enabled by default by any drupal module.

A module is a container for a unit of code in Drupal. In Drupal7 a module consists of at a minimum a folder and a module info file. This is the mechanism used by Drupal to say “here is my code for Drupal to run”. Some modules such as Migrate, LDAPOrganic Groups and Views contain submodules. These submodules are themselves simply directories with .info files and .module files which contain code for Drupal to execute.

If you’re going to interact with or update a Database for instance. You’ll likely want to implement:

While Drupal modules may seem complex. They offer a useful method of encapsulation for your custom code — they are simply as simple or complicated as you need to perform your business logic.

Looking for quality Drupal Web Hosting? Look no further than Arvixe Web Hosting

!

Tags: , , , , , , , , , , , , | Posted under Drupal | RSS 2.0

Author Spotlight

David Gurba

I am a web programmer currently employed at UCSB. I have been developing web applications professionally for 8+ years now. For the last 5 years I’ve been actively developing websites primarily in PHP using Drupal. I have experience using LAMP and developing data driven websites for clients in aviation, higher education and e-commerce. If you’d like to contact me I can be reached at david.gurba@arvixe.com

Leave a Reply

Your email address will not be published. Required fields are marked *