While creating a new Drupal 7 module, sometimes we need to interact with database. Moreover, we need to create our own table for the module we are creating. This can be achieved using a .install file. We can create tables for modules manually using MySQL GUI tools, but if we want to make our module install able in any Drupal 7 intallation server then we should create a .install file.
Below are the steps on how to create a .install file:
Below are the steps on how to create a .install file:
- Open a text editor, i prefer Notepad++.
- Create a new file.
- Add your install code in the file, sample code is shown in the screenshot below.
- Place the file in the module directory, See here on how to create a simple module.
Now when you install the module form admin module section your table will be automatically created in the database.
No comments:
Post a Comment