开发者

How to create a database table in an installation file for a Drupal Module?

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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜