Magento 1.9自定义模块与自定义数据库表不保存

时间:2016-08-08 10:42:53

标签: magento model magento-1.9

我开发了一个自定义模块,它也有一个自定义数据库表。 但是,由于出现以下错误,我无法插入记录:

Fatal error: Call to a member function beginTransaction() on boolean in /httpdocs/includes/src/__default.php on line 6105

以下是我正在尝试的代码:

$data = array(
          'voucher'     => 'voucher',
          'customer_name' => 'customer_name',
          'order'           => 'order',
          'value'           => 'value',
          'status'      => 1,
          'date'            => '',
        );
$model = Mage::getModel('antikatavoles/antikatavoles')->setData($data);

这是我的配置文件:

<?xml version="1.0" ?>
<config>

<modules>
    <ID_Antikatavoles>
        <version>0.1.0</version>
    </ID_Antikatavoles>
</modules>

<frontend>
    <routers>
        <antikatavoles>
            <use>standard</use>
            <args>
                <module>ID_Antikatavoles</module>
                <frontName>antikatavoles</frontName>
            </args>
        </antikatavoles>
    </routers>
</frontend>  
<global>
    <models>
        <antikatavoles>
            <class>ID_Antikatavoles_Model</class>
            <resourceModel>antikatavoles_mysql4</resourceModel>
        </antikatavoles>
        <antikatavoles_mysql4>
            <class>ID_Antikatavoles_Model_Mysql4</class>
            <entities>
                <antikatavoles>
                    <table>antikatavoles</table>
                </antikatavoles>
            </entities>
        </antikatavoles_mysql4>
    </models>
    <resources>
        <antikatavoles_setup>
            <setup>
                <module>ID_Antikatavoles</module>
            </setup>
            <connection>
                <use>core_setup</use>
            </connection>
        </antikatavoles_setup>
        <antikatavoles_write>
            <connection>
                <use>core_write</use>
            </connection>
        </antikatavoles_write>
        <antikatavoles_read>
            <connection>
                <use>core_read</use>
            </connection>
        </antikatavoles_read>
    </resources>
    <helpers>
        <antikatavoles>
            <class>ID_Antikatavoles_Helper</class>
        </antikatavoles>
    </helpers>
</global>

</config>

任何人都可以帮我解决这个问题吗?

谢谢!

编辑:

我的模型和资源模型:

class ID_Antikatavoles_Model_Antikatavoles extends Mage_Core_Model_Abstract
{
    public function _construct()
    {
        parent::_construct();
        $this->_init('antikatavoles/antikatavoles');
    }
}

class ID_Antikatavoles_Model_Mysql4_Antikatavoles extends Mage_Core_Model_Mysql4_Abstract
{
    public function _construct()
    {  
        $this->_init('antikatavoles/antikatavoles', 'antikatavoles_id');
    }
}

0 个答案:

没有答案