dbModel 读取资源未在 Magento 版本 1.3.2.4 中实现 Zend_Db_Adapter_Abstract [英] dbModel read resource does not implement Zend_Db_Adapter_Abstract in Magento ver 1.3.2.4

查看:16
本文介绍了dbModel 读取资源未在 Magento 版本 1.3.2.4 中实现 Zend_Db_Adapter_Abstract的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我为我的 Magento 项目创建了一个自定义模块.该模块适用于 Magento 1.6.X .但是当我在 Magento 版本 1.3.2.4 中安装这个扩展时.Magento 抛出以下错误.

I was created a custom module for my Magento project. This module works in Magento 1.6.X . But while i install this extension in Magento version 1.3.2.4 . Magento throws below error.

dbModel read resource does not implement Zend_Db_Adapter_Abstract

许多论坛讨论了这个问题.但不幸的是.我没有得到任何结果.

Many Forums discussed this issue. But unfortunately. I don't get any results.

我清除了缓存,重新索引.我还应该怎么做才能解决这个问题.

I cleared cache, Reindexed. What else should i do to solve this one.

Var 文件夹权限设置777.即使我尝试过全新的 Magento 安装,但同样的错误.

Var folder permission is setuped 777. Even I tried in fresh Magento installation but same error.

提前致谢.

推荐答案

对于那个版本的 Magento (1.3.2.4),你需要在你的 config.xml 文件中指定读写连接.

For that version of Magento (1.3.2.4), you need to specify read and write connections in your config.xml file.

下,添加一个 节点,如下所示:

Under <global>, add a <resources> node like so:

<resources>
    <yourModelNode_write>
        <connection>
            <use>core_write</use>
        </connection>
    </yourModelNode_write>
    <yourModelNode_read>
        <connection>
            <use>core_write</use>
        </connection>
    </yourModelNode_read>
</resources>

确保刷新缓存!

这种类型的配置在 Magento 的后续版本中是可选的;如果您没有在配置中指定它们,系统将加载默认的读/写连接.我不确定这个特性是什么时候实现的,但它存在于 1.6.x 中.

This type of configuration is optional in later releases of Magento; the system will load the default read/write connections if you don't specify them in your config. I'm not sure when exactly this feature was implemented, but it is present in 1.6.x.

1.3.2.4 和 1.6.x 的区别在于 Mage_Core_Model_Resource::getConnection().

The difference between 1.3.2.4 and 1.6.x is located in Mage_Core_Model_Resource::getConnection().

1.6.x 将返回默认的读/写连接,如果你没有在你的 config.xml 中指定:

1.6.x will return the default read/write connection if you don't have one specified in your config.xml:

Mage_Core_Model_Resource::getConnection()

Mage_Core_Model_Resource::getConnection()

$connConfig = Mage::getConfig()->getResourceConnectionConfig($name);

if (!$connConfig) {
    $this->_connections[$name] = $this->_getDefaultConnection($name);
    return $this->_connections[$name];
}

1.3.2.4 将返回 false:

1.3.2.4 will return false:

$connConfig = Mage::getConfig()->getResourceConnectionConfig($name);

if (!$connConfig || !$connConfig->is('active', 1)) {
    return false;
}

你得到不实现 Zend_Db_Adapter_Abstract"错误的原因位于 Varien_Data_Collection_Db::setConnection():

The reason why you get the "does not implement Zend_Db_Adapter_Abstract" error is located in Varien_Data_Collection_Db::setConnection():

public function setConnection($conn)
{
    if (!$conn instanceof Zend_Db_Adapter_Abstract) {
        throw new Zend_Exception('dbModel read resource does not implement Zend_Db_Adapter_Abstract');
    }

    $this->_conn = $conn;
    $this->_select = $this->_conn->select();
}

false 作为连接 ($conn) 传入时,它会抛出这个错误,因为 -- 当然 -- false 不是 Zend_Db_Adapter_Abstract 的实例.

When false is passed in as the connection ($conn), it'll throw this error because -- of course -- false is not an instance of Zend_Db_Adapter_Abstract.

这篇关于dbModel 读取资源未在 Magento 版本 1.3.2.4 中实现 Zend_Db_Adapter_Abstract的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆