我正在使用 WAMP 服务器在 magento 1.6.2.0 上创建我的模块;当我尝试将我的表添加到magento数据库时出现异常,并且在Mysql页面中我的表a没有创建但我在表“core_ressource”下找到了我的模块的名称;你能帮我吗 ?
这是我的 PHP 升级页面:
<?php
$installer = $this;
$installer->startSetup();
/**
* Create table 'interactivebanner/interactivebanner'
*/
$table = $installer->getConnection()
->newTable($installer->getTable('interactivebanner/interactivebanner'))
->addColumn('entity_id', Varien_Db_Ddl_Table::TYPE_INTEGER, null, array(
'identity' => true,
'unsigned' => true,
'nullable' => false,
'primary' => true,
), 'Entity Id')
->addColumn('name', Varien_Db_Ddl_Table::TYPE_TEXT,100, array(
'nullable' => false,
'default' => '',
), 'Name')
->addColumn('link', Varien_Db_Ddl_Table::TYPE_TEXT,255, array(
'nullable' => false,
'default' => '',
), 'Link')
->addColumn('status', Varien_Db_Ddl_Table::TYPE_INTEGER,null, array(
'unsigned' => true,
'nullable' => false,
'default' => '0',
), 'Status');
$installer->getConnection()->createTable($table);
/**
* Create table 'interactivebanner/interactivebannerprod'
*/
$table = $installer->getConnection()
->newTable($installer->getTable('interactivebanner/interactivebannerprod'))
->addColumn('value_id', Varien_Db_Ddl_Table::TYPE_INTEGER, null, array(
'identity' => true,
'nullable' => false,
'primary' => true,
), 'Value ID')
->addColumn('tag_content', Varien_Db_Ddl_Table::TYPE_TEXT, 255, array(
'nullable' => false,
'default' => '',
), 'Status id')
->addColumn('entity_id', Varien_Db_Ddl_Table::TYPE_INTEGER, null, array(
'unsigned' => true,
'nullable' => false,
'default' => '0',
), 'Entity Id')
->addColumn('position_v', Varien_Db_Ddl_Table::TYPE_TEXT,10, array(
'nullable' => false,
'default' => '0',
), 'Position V')
->addColumn('position_h', Varien_Db_Ddl_Table::TYPE_TEXT,10, array(
'nullable' => false,
'default' => '0',
), 'Position H')
->addForeignKey($installer->getFkName('interactivebanner/interactivebanner', 'entity_id', 'interactivebanner/interactivebannerprod', 'entity_id'),
'entity_id', $installer->getTable('interactivebanner/interactivebannerprod'), 'entity_id', Varien_Db_Ddl_Table::ACTION_CASCADE, Varien_Db_Ddl_Table::ACTION_CASCADE);
$installer->getConnection()->createTable($table);
$installer->endSetup();
这是一个例外:
Exception Object
(
[message:protected] => Notice: Trying to get property of non-object in C:\wamp\www\ce_1.6.2.0\app\code\core\Mage\Core\Model\Resource.php on line 230
[string:Exception:private] =>
[code:protected] => 0
[file:protected] => C:\wamp\www\ce_1.6.2.0\app\code\core\Mage\Core\functions.php
[line:protected] => 245
[trace:Exception:private] => Array
(
[0] => Array
(
[file] => C:\wamp\www\ce_1.6.2.0\app\code\core\Mage\Core\Model\Resource.php
[line] => 230
[function] => mageCoreErrorHandler
[args] => Array
(
[0] => 8
[1] => Trying to get property of non-object
[2] => C:\wamp\www\ce_1.6.2.0\app\code\core\Mage\Core\Model\Resource.php
[3] => 230
[4] => Array
(
[model] => Kiwi_InteractiveBanner_Resource
[entity] => interactivebanner
[modelsNode] => Mage_Core_Model_Config_Element Object
(
[varien] => Mage_Core_Model_Config_Element Object
(
[class] => Varien
)
[core] => Mage_Core_Model_Config_Element Object
(
[class] => Mage_Core_Model
[resourceModel] => core_resource
)
[core_resource] => Mage_Core_Model_Config_Element Object
(
[class] => Mage_Core_Model_Resource
[deprecatedNode] => core_mysql4
[entities] => Mage_Core_Model_Config_Element Object
(
[config_data] => Mage_Core_Model_Config_Element Object
(
[table] => core_config_data
)
[website] => Mage_Core_Model_Config_Element Object
(
[table] => core_website
)
[store] => Mage_Core_Model_Config_Element Object
(
[table] => core_store
)
[resource] => Mage_Core_Model_Config_Element Object
(
[table] => core_resource
)
[cache] => Mage_Core_Model_Config_Element Object
(
[table] => core_cache
)
[cache_tag] => Mage_Core_Model_Config_Element Object
(
[table] => core_cache_tag
)
[cache_option] => Mage_Core_Model_Config_Element Object
(
[table] => core_cache_option
)
[store_group] => Mage_Core_Model_Config_Element Object
(
[table] => core_store_group
)
[config_field] => Mage_Core_Model_Config_Element Object
(
[table] => core_config_field
)
[email_template] => Mage_Core_Model_Config_Element Object
(
[table] => core_email_template
)
[variable] => Mage_Core_Model_Config_Element Object
(
[table] => core_variable
)
[variable_value] => Mage_Core_Model_Config_Element Object
(
[table] => core_variable_value
)
[translate] => Mage_Core_Model_Config_Element Object
(
[table] => core_translate
)
[session] => Mage_Core_Model_Config_Element Object
(
[table] => core_session
)
[layout_update] => Mage_Core_Model_Config_Element Object
(
[table] => core_layout_update
)
[layout_link] => Mage_Core_Model_Config_Element Object
(
[table] => core_layout_link
)
[url_rewrite] => Mage_Core_Model_Config_Element Object
(
[table] => ...
这是我的 config.xml 的一部分
<models>
<interactivebanner>
<class>Kiwi_InteractiveBanner_Model</class>
<resourceModel>Kiwi_InteractiveBanner_Resource</resourceModel>
</interactivebanner>
<interactivebanner_resource>
<class>Kiwi_InteractiveBanner_Model_Resource</class>
<entities>
<interactivebanner>
<table>interactivebanner</table>
</interactivebanner>
<interactivebannerprod>
<table>interactivebannerprod</table>
</interactivebannerprod>
</entities>
</interactivebanner_resource>
</models>