Magento database fetch mode

I was used to write $modelName->column_name to get attribute value in database. It requires $resource->_getReadAdapter()->setFetchMode(Zend_Db::FETCH_OBJ);.

However, it is not Magento’s default fetch mode (default is Zend_Db:FETCH_ASSOC). Whenever fetch mode is changed, it must be changed back to the default after using it. Otherwise, method getCollection() of ALL models will stop working. There may be other side effects if you leave the adapter’s fetch mode changed.

Leave a comment

Your email address will not be published. Required fields are marked *