I am creating a module for Drupal 7.x, and I want to create a database table开发者_JAVA技巧 when the module is installed (enabled for the first time). How can I do this? Thanks.
Old post, I know, but for the sake of completeness:
hook_install_schema and hook_uninstall_schema are no longer necessary as of drupal 7.x
http://api.drupal.org/api/drupal/includes--database--schema.inc/group/schemaapi
You can get away with just implementing hook_schema().
You need to implement install_schema
and uninstall_schema
hooks in your module that return schema information. These are translated into table create and drop and executed by Drupal when your module is enabled or uninstalled. Read more in the Schema API.
精彩评论