dbModel read resource does not implement Zend_Db_Adapter_Abstract in Magento ver 1.3.2.4

StackOverflow https://stackoverflow.com/questions/10362601

  •  04-06-2021
  •  | 
  •  

Question

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 folder permission is setuped 777. Even I tried in fresh Magento installation but same error.

Thanks In Advance.

Was it helpful?

Solution

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>

Make sure to refresh your cache!

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.

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

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()

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

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

1.3.2.4 will return false:

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

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

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();
}

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.

OTHER TIPS

In my case, simply helped Clearing files/directories under MAGENTO_ROOT/var/cache/ directory resolved the issue.

dbModel read resource does not implement Zend_Db_Adapter_Abstract

Whatever class dbModel is, it needs to implement Zend_Db_Adapter_Abstract. This is something called an interface. If you want to know more what an interface is I would look here to see how it related to PHP (http://php.net/manual/en/language.oop5.interfaces.php)

So basically whatever dbModel is, you need to make sure its class definition contains "implements Zend_Db_Adapter_Abstract" after the class name.

Without knowing what you are trying to accomplish with your module that is about all I can tell you (basically explain the error). I have a suspicion that dbModel is a core Magento object and if that is the case I believe that you are caught up in a incompatibility between the two versions of Magento.

However, if dbModel is one of your classes, adding the implements to your class definition should clear the error up.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top