1

当我包含 $installer->createEntityTables( $this->getTable('red/red') ); 时出现此错误

我正在使用企业 1.11,我还看到了替代方案,即键入所有非常耗时的东西。有人可以告诉我谁使这个功能起作用。

    [previous:Exception:private] => 
    [xdebug_message] => ( ! ) Mage_Eav_Exception: Can't create table: red_faqs_eavexample in C:\wamp\www\ubt.onlocal.com.au\app\Mage.php on line 549
Call Stack
#TimeMemoryFunctionLocation
10.0003690528{main}(  )..\index.php:0
20.00271167384Mage::run(  )..\index.php:81
30.01012776112Mage_Core_Model_App->run(  )..\Mage.php:640
40.02304545784Mage_Core_Model_App->_initModules(  )..\App.php:338
50.46364871080Mage_Core_Model_Resource_Setup::applyAllUpdates(  )..\App.php:412
60.528411772936Mage_Core_Model_Resource_Setup->applyUpdates(  )..\Setup.php:235
70.528611769664Mage_Core_Model_Resource_Setup->_installResourceDb(  )..\Setup.php:327
80.528611769824Mage_Core_Model_Resource_Setup->_modifyResourceDb(  )..\Setup.php:421
90.529511778144include( 'C:\wamp\www\ubt.onlocal.com.au\app\code\local\Magelocal\Red\sql\red_setup\install-0.1.0.php' )..\Setup.php:624
100.529711778712Mage_Eav_Model_Entity_Setup->createEntityTables(  )..\install-0.1.0.php:6

)
Error in file: "C:\wamp\www\ubt.onlocal.com.au\app\code\local\Magelocal\Red\sql\red_setup\install-0.1.0.php" - Can't create table: red_faqs_eavexample

#0 C:\wamp\www\ubt.onlocal.com.au\app\code\core\Mage\Core\Model\Resource\Setup.php(645): Mage::exception('Mage_Core', 'Error in file: ...')
#1 C:\wamp\www\ubt.onlocal.com.au\app\code\core\Mage\Core\Model\Resource\Setup.php(421): Mage_Core_Model_Resource_Setup->_modifyResourceDb('install', '', '0.1.0')
#2 C:\wamp\www\ubt.onlocal.com.au\app\code\core\Mage\Core\Model\Resource\Setup.php(327): Mage_Core_Model_Resource_Setup->_installResourceDb('0.1.0')
#3 C:\wamp\www\ubt.onlocal.com.au\app\code\core\Mage\Core\Model\Resource\Setup.php(235): Mage_Core_Model_Resource_Setup->applyUpdates()
#4 C:\wamp\www\ubt.onlocal.com.au\app\code\core\Mage\Core\Model\App.php(412): Mage_Core_Model_Resource_Setup::applyAllUpdates()
#5 C:\wamp\www\ubt.onlocal.com.au\app\code\core\Mage\Core\Model\App.php(338): Mage_Core_Model_App->_initModules()
#6 C:\wamp\www\ubt.onlocal.com.au\app\Mage.php(640): Mage_Core_Model_App->run(Array)
#7 C:\wamp\www\ubt.onlocal.com.au\index.php(81): Mage::run('', 'store')
#8 {main}
4

1 回答 1

1

这是一个不应该触发错误的问题。长话短说,MySQL 不支持 DDL 事务,并且在该方法的过程中,在 SQL 中发现了 DDL 例程并引发了错误。

简单的答案是注释掉这一行:


lib/Varien/Db/Adapter/PDO/Mysql.php

protected function _checkDdlTransaction($sql)
{
    if (is_string($sql) && $this->getTransactionLevel() > 0) {
        $startSql = strtolower(substr(ltrim($sql), 0, 3));
        if (in_array($startSql, $this->_ddlRoutines)) {
            // comment this out: trigger_error(Varien_Db_Adapter_Interface::ERROR_DDL_MESSAGE, E_USER_ERROR);
        }
    }
}

这样做可以安装您的模块。显然,破解核心文件是一个糟糕的主意。您应该扩展该方法或允许 SQL 运行,然后将生成的 SQL 转换为 Magento MySQL API,如核心 sql 设置脚本中所示。后者是一个主要的痛苦......更好的想法是扩展该方法。

更多关于背景信息和故障排除的信息。

于 2012-09-23T02:14:40.943 回答