magento----使用magento机制安装数据表

过程中注意事项:

当安装一个表的时候,就会在core_resource中加入一条数据,来记录改数据表的版本情况。

在安装过程中,如果mysql4-install-0.1.0.php有错误,该表不能建立,但是在core_resource表中还是加入了该<setup>的信息,故下次调试的时候记住,到表core_resource中删除对用的那条数据,否则,安装不上~!!!!

2.1

app/ect/modules/

2.2

app/code/community/AQ/Gao/etc/config.xml

app/code/community/AQ/Gao/sql/gao_setup/mysql4-install-0.1.0.php

只需要建这两个文件就可以完成,当然是最简单的方式了。

2.3

编辑config.xml文件

2.3.1

<modules>

<frontend>

<global>

<models/>

<resources>

<gao_setup>

<setup>

<module />

</setup>

<connection>

<use>core_setup</use>

</connection>

</gao_setup>

</resources>

</global>

2.4

编辑

mysql4-install-0.1.0.php

一定别把`当成',擦!!,,,,`````````,此符号是在英文状态下esc下面的那个键打出来的符号,擦!

附文件:

app/code/community/AQ/Gao/etc/config.xml

----->

<?xml version="1.0"?>

<config>

<modules>

<AQ_Gao>

<version>0.1.0</version>

</AQ_Gao>

</modules>

<frontend>

<routers>

<gao>

<use>standard</use>

<args>

<module>AQ_Gao</module>

<frontName>gao</frontName>

</args>

</gao>

</routers>

</frontend>

<global>

<models>

<gao>

<class>AQ_Gao_Model</class>

<resourceModel>gao_mysql4</resourceModel>

</gao>

<gao_mysql4>

<class>AQ_Gao_Model_Mysql4</class>

<entities>

<gao>

<table>aagao</table>

</gao>

</entities>

</gao_mysql4>

</models>

<resources>

<gao_setup>

<setup>

<module>AQ_Gao</module>

</setup>

<connection>

<use>core_setup</use>

</connection>

</gao_setup>

<gao_write>

<connection>

<use>core_write</use>

</connection>

</gao_write>

<gao_read>

<connection>

<use>core_read</use>

</connection>

</gao_read>

<weblog_setup>

<setup>

<module>AQ_Gao</module>

</setup>

<connection>

<use>core_setup</use>

</connection>

</weblog_setup>

</resources>

</global>

</config>

app/code/community/AQ/Gao/sql/gao_setup/mysql4-install-0.1.0.php

----->

<?php

$installer = $this;

$installer->startSetup();

try{

$installer->run("

DROP TABLE IF EXISTS {$this->getTable('gao/gao')};

CREATE TABLE {$this->getTable('gao/gao')} (

`post_id` int( 11 ) unsigned NOT NULL AUTO_INCREMENT ,

`cat_id` smallint( 11 ) NOT NULL default '0',

`title` varchar( 255 ) NOT NULL default '',

`post_content` text NOT NULL ,

`status` smallint( 6 ) NOT NULL default '0',

`created_time` datetime default NULL ,

`update_time` datetime default NULL ,

`identifier` varchar( 255 ) NOT NULL default '',

`user` varchar( 255 ) NOT NULL default '',

`update_user` varchar( 255 ) NOT NULL default '',

`meta_keywords` text NOT NULL ,

`meta_description` text NOT NULL ,

`comments` TINYINT( 11 ) NOT NULL,

PRIMARY KEY ( `post_id` ) ,

UNIQUE KEY `identifier` ( `identifier` )

) ENGINE = InnoDB DEFAULT CHARSET = utf8;

INSERT INTO {$this->getTable('gao/gao')} (`post_id` ,`cat_id`, `title` ,`post_content` ,`status` ,`created_time` ,`update_time` ,`identifier` ,`user` ,`update_user` ,`meta_keywords` ,`meta_description`)

VALUES (NULL ,'0', 'Hello World', 'Welcome to Magento Blog by aheadWorks Co. This is your first post. Edit or delete it, then start blogging!', '1', NOW( ) , NOW( ) , 'Hello', 'Joe Blogs', 'Joe Blogs', 'Keywords', 'Description');

");

}catch(Exception $e){}

$installer->endSetup();

------------------------->KO!!!

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值