首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >是否在禁用编译器时安装程序sql不运行?

问是否在禁用编译器时安装程序sql不运行?
EN

Stack Overflow用户
提问于 2015-06-08 06:55:22
回答 1查看 51关注 0票数 0

我的问题是指一个CMS magento。我已经创建了一个脚本sql安装程序,在我的服务器上,当我访问mysql和搜索时,我找不到我用脚本创建的新列。我的代码是:

代码语言:javascript
复制
<?php 

$installer = new Mage_Sales_Model_Resource_Setup('core_setup');

//entities for options in table Sales Flat Order Item
$entities = array(
    'order_item'
);

//entity for desactivate_count in table Sales Flat Order
$entitydes = array(
    'order'
);

//for type text
$optionstxt = array(
    'type'     => 'text',
    'grid' => false
);

//for type int
$optionsint = array(
    'type' => 'int',
    'grid' => false,
    'default' => '0'
    );

//just for column incomm_desactivate_count
$optionsdesc = array(
    'type' => 'int',
    'grid' => true,
    'default' => '0'
    );

foreach ($entities as $entity) {
    $installer->addAttribute($entity, 'incomm_request_active_code', $options);
    $installer->addAttribute($entity, 'incomm_cancel', $options);
    $installer->addAttribute($entity, 'incomm_exception_count', $optionsint); //value int(2)
    $installer->addAttribute($entity, 'incomm_return_active_code', $options);
    $installer->addAttribute($entity, 'incomm_activated', $optionsint); //value int(1)
}

foreach ($entitydes as $entity) {
    $installer->addAttribute($entity, 'incomm_desactivate_count', $optionsdesc); //value int(2)
}

$installer->endSetup();

我找到了Magento Module SQL does not run,一条评论说在我的自定义模块magento中编译并执行安装程序sql。我想知道为什么要这么做。在此链接中,我找不到更多信息。

EN

回答 1

Stack Overflow用户

发布于 2015-06-08 14:07:48

你不需要编译就能运行升级脚本。事实上,我认为您可能需要暂时关闭编译才能运行升级脚本(但我对此不太确定)。

这取决于模块版本的值,该值存储在Magento数据库的core_resource表中。

你的模块

代码语言:javascript
复制
config.xml  [configuraton-file] - The version number resides in this.

sql (folder) > *.php [upgrade php scripts]

现在,Magento在以下情况下在模块中运行升级脚本(两者均为真):

  1. config.xml中模块的版本号大于"core_resource“模块中模块的版本号。
  2. 具有config.xml文件中声明的新版本的脚本驻留在模块的sql文件夹中。Magento在文件命名约定方面非常独特。

我认为你的模块在core_resource表中的版本号已经是最新的版本了,所以它不会搜索任何升级脚本。所以,我建议你在Magento db的core_resource表中删除你的模块条目或者减少版本号。然后按照Mageto标准维护文件,您的升级脚本就会运行。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/30699307

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档