Use the hook_field_schema function from your custom module’s .install file

Many custom modules will not need to add information directly to your MySQL database. But if you do want to store new info from your module, you’ll need to include a .install file with your .module and .info files and use the hook function listed above to do this.

This references a great book that I picked up from Yeah, I know; another shameless plug. But it is worth it.

This is the code that you need to place in your install file. You’ll note that it looks similar to the SQL statements that you would use to add the info manually.

* Implements hook_field_schema()
function countryinfo_field_schema() {
$columns = array(
‘country’ => array(
‘description’ => ‘Two letter ISO country code of this
‘type’ => ‘varchar’,
‘length’ => 2,
‘not null’ => FALSE,
‘default’ => ”,
return array(
‘columns’ => $columns,

If this is the type of development you want to be able to do, take a look at the book at

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: