Custom table magento module

The tutorial explains how to create custom table magento module. Here its create the following custom table as part of magento extensions /module.

This table is creating as part of the magento module which save contact form data to the database on form submissions. Please refer the tutorial which gives step by step explanation of magento module that save data to the database on form submissions.

custom table magento module

Add the following code in app\code\local\Save\Contactform\sql\save_contactform_setup\install-0.1.0.php..Click here find how to include the install script in the config file.

$installer = $this;

$installer->startSetup();

$installer->run("

DROP TABLE IF EXISTS `{$this->getTable('contact_table')}`;
CREATE TABLE `{$this->getTable('contact_table')}` (
  `contact_id` int(11) unsigned NOT NULL auto_increment,
  `created_at` TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
  `name` varchar(25) NULL default '',
  `email` varchar(50) NULL default '',
  `telephone` varchar(50) NULL default '',
  `comment` varchar(250) NULL default '',
  PRIMARY KEY (`contact_id`),
  INDEX (contact_id)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

");

$installer->endSetup();

Share this Tutorial