使用我的新magento模块后:SQLSTATE [42S02]:找不到基表或视图:1146表XXX

des*_*est 2 magento

SQLSTATE [42S02]:找不到基表或视图:1146表'desbest_full2.showdown_matches'不存在

但是,如果我内部有一个mysql安装脚本,为什么呢 app/code/local/Desbest/Showdown/sql/Showdown_setup/mysql4-install-1.php

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

$installer = $this;
/* @var $installer Mage_Catalog_Model_Resource_Eav_Mysql4_Setup */
$installer->startSetup();
$installer->run("

    CREATE TABLE {$this->getTable('showdown_matches')} (
    --CREATE TABLE IF NOT EXISTS `showdown_matches` (
      `id` int(11) NOT NULL AUTO_INCREMENT,
      `firstproductid` int(11) NOT NULL,
      `secondproductid` int(11) NOT NULL,
      `title` varchar(255) NOT NULL,
      `datenumber` varchar(10) NOT NULL,
      PRIMARY KEY (`id`)
    ) ENGINE=InnoDB DEFAULT CHARSET=utf8_general_ci AUTO_INCREMENT=1 ;

    CREATE TABLE IF NOT EXISTS `showdown_votes` (
      `id` int(11) NOT NULL AUTO_INCREMENT,
      `matchid` int(11) NOT NULL,
      `votedfor` varchar(10) NOT NULL,
      `ip` varchar(50) NOT NULL,
      `datenumber` varchar(10) NOT NULL,
      PRIMARY KEY (`id`)
    ) ENGINE=InnoDB DEFAULT CHARSET=utf8_general_ci AUTO_INCREMENT=1 ;



");
$installer->endSetup();
Run Code Online (Sandbox Code Playgroud)

该模块适用于我最初的Magento安装.

mtt*_*son 5

您的安装脚本可能未运行,因为Magento认为它已经运行.您可以使用模块版本检查数据库表core_resource以获取模块的记录.此资源记录是Magento如何知道它是否已运行模块设置脚本,或确定是否需要将旧版本的升级脚本运行到较新版本.

如果从core_resource表中删除模块的记录,Magento将在下次Magento生成页面时尝试执行您的设置脚本.

我还希望您需要die("Exit for now");从安装脚本中删除它,以便它实际到达创建表的部分.如果安装脚本启动并调用die()函数并结束该脚本的执行,我认为它可以继续创建core_resource记录,指示它已完成安装脚本并且不会再次运行它,除非您从中删除该记录core_resource表.

您可以在Magento知识库中找到有关设置脚本的一些信息: Magento for Developers:第6部分 - Magento设置资源

您还可以检查模块配置XML文件,以确保其中的版本与安装脚本的文件名版本相匹配.

<modules>
    <Desbest_Showdown>
        <version>1</version>
    </Desbest_Showdown>
</modules>
<global>
    <resources>
        <showdown_setup>
            <setup>
                <module>Desbest_Showdown</module>
            </setup>
        </showdown_setup>
    </resources>
</global>
Run Code Online (Sandbox Code Playgroud)

我想到的另一件事是文件/目录名称区分大小写.如果您在Mac上设置了一堆不透明的文件系统,那么一切正常,然后将文件移动到文件系统区分大小写的linux框中,您将遇到文件无法找到的问题.您列出了您的文件名app/code/local/Desbest/Showdown/sql/Showdown_setup/mysql4-install-1.php,我认为该目录Showdown_setup可能需要全部小写showdown_setup.