1、config.xml配置
-
<models>
-
<home>
-
<class>Handheld_Home_Model</class>
-
<resourceModel>home_mysql4</resourceModel>
-
</home>
-
<home_mysql4>
-
<class>Handheld_Home_Model_Resource_Mysql4</class>
-
<entities>
-
<home_middlepart>
-
<table>home_middlepart</table>
-
</home_middlepart>
-
</entities>
-
</home_mysql4>
-
</models>
2、sql文件
命名:install-版本号.php
-
$installer = $this;
-
-
-
-
-
$installer->startSetup();
-
-
-
-
-
$table = $installer->getConnection()
-
->newTable($installer->getTable('home/slideshow'))
-
->addColumn('id', Varien_Db_Ddl_Table::TYPE_INTEGER, null, array(
-
'identity' => true,
-
'unsigned' => true,
-
'nullable' => false,
-
'primary' => true,
-
), 'slideshow Id')
-
->addColumn('title', Varien_Db_Ddl_Table::TYPE_TEXT, 255, array(
-
), 'slideshow Name')
-
->addColumn('is_active', Varien_Db_Ddl_Table::TYPE_SMALLINT, null, array(
-
'default' => '1',
-
), 'Active status')
-
->addColumn('sort_order', Varien_Db_Ddl_Table::TYPE_INTEGER, null, array(
-
'default' => '1',
-
), 'sort_order')
-
->addColumn('description', Varien_Db_Ddl_Table::TYPE_TEXT, "64k", array(
-
), 'slideshow Description')
-
->addColumn('link', Varien_Db_Ddl_Table::TYPE_TEXT, 255, array(
-
), 'slideshow Link Url')
-
->addColumn('url', Varien_Db_Ddl_Table::TYPE_TEXT, 255, array(
-
), 'slideshow Url')
-
->addColumn('created_at', Varien_Db_Ddl_Table::TYPE_TIMESTAMP, null, array(
-
), 'Creation Time')
-
->addColumn('updated_at', Varien_Db_Ddl_Table::TYPE_TIMESTAMP, null, array(
-
), 'Updated Time')
-
-
-
->setComment('Slideshow');
-
$installer->getConnection()->createTable($table);
-
$installer->endSetup();
3、如需更改表或新添加表,只需升级版本号,并且添加sql文件upgrade-原版本号-新版本号.php文件,内容为更改表的内容或新添加的表
(责任编辑:最模板) |