Test Mangento database install file

File: app/code/local/PackageName/ModuleName/Model/Setup/Mysql4/Setup.php

class PackageName_ModuleName_Model_Setup_Mysql4_Setup extends Mage_Core_Model_Resource_Setup 
{
}

File: app/core/local/PackageName/ModuleName/sql/module_setup/mysql4-install-0.1.0.php

echo 'Running This Upgrade: '.get_class($this)."\n <br /> \n";
die("Exit for now");

删除表中相应模块的数据

DELETE from core_resource where code = ‘moduleName_setup’;
DROP TABLE modulename_tb;

安装脚本

$installer = $this;
$installer->startSetup();
$installer->run(”

CREATE TABLE `{$installer->getTable(‘modulename/modulename_tb’)}` (
`modulename_id` int(11) NOT NULL auto_increment,
`title` text,
`post` text,
`date` datetime default NULL,
`timestamp` timestamp NOT NULL default CURRENT_TIMESTAMP,
PRIMARY KEY  (`modulename_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

INSERT INTO `{$installer->getTable(‘modulename/modulename_tb’)}` VALUES (1,’My New Title’,'This is a blog post’,’2009-07-01 00:00:00′,’2009-07-02 23:12:30′);
“);
$installer->endSetup();

$installer = $this; $this是指PackageName/ModuleName/Model/Setup/Mysql4/Setup

你可能感兴趣的:(Test Mangento database install file)