Magento-致命错误:类名必须是有效对象或字符串 [英] Magento - Fatal error: Class name must be a valid object or a string

查看:64
本文介绍了Magento-致命错误:类名必须是有效对象或字符串的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在安装Magento时遇到问题,希望有人可以帮助我.

I'm having a problem with a Magento installation that I hope someone can help me with.

当我访问该网站时,我突然开始收到以下错误消息:

I suddenly started getting the following error message when I accessed the site:

Fatal error: Class name must be a valid object or a string in /app/code/core/Mage/Core/Model/Resource.php on line 215

此功能指的是:

/**
  * Get connection type instance
  *
  * Creates new if doesn't exist
  *
  * @param string $type
  * @return Mage_Core_Model_Resource_Type_Abstract
  */
public function getConnectionTypeInstance($type)
{
    if (!isset($this->_connectionTypes[$type])) {
        $config = Mage::getConfig()->getResourceTypeConfig($type);
        $typeClass = $config->getClassName();
        $this->_connectionTypes[$type] = new $typeClass();
    }
    return $this->_connectionTypes[$type];
}

这是第215行:

$this->_connectionTypes[$type] = new $typeClass();

我一直在寻找问题相似的人,但没有任何运气,所以我被困住了,真的需要解决这个问题

I've searched for someone with a similar issue but not had any luck so i'm stuck and really need to get this resolved

任何人都可以帮忙吗?

推荐答案

我在这里遇到了同样的问题. 尝试添加

I had the same problem here. Try to add

<type>pdo_mysql</type>

在连接节点内的 local.xml 文件中

.应该是这样的:

in your local.xml file inside the connection node. It should be something like this:

        <default_setup>
            <connection>
                <host><![CDATA[localhost]]></host>
                <username><![CDATA[your_user]]></username>
                <password><![CDATA[your_pass]]></password>
                <dbname><![CDATA[your_db]]></dbname>
                <initStatements><![CDATA[SET NAMES utf8]]></initStatements>
                <model><![CDATA[mysql4]]></model>
                <type><![CDATA[pdo_mysql]]></type>
                <pdoType><![CDATA[]]></pdoType>
                <active>1</active>
            </connection>
        </default_setup>

还要在自动格式化xml配置文件时尝试检查编辑器是否添加了换行符或空格.有时 type 节点(和其他节点)的值放在下面的行中,它破坏了解析.因此,请确保xml文件中的值周围没有空格或换行符.

And also try to check if your editor added line breaks or blank spaces when auto-formating your xml configuration file. Sometimes the value for the type node (and other nodes) are placed in the line bellow, and it breaks the parse. So, make sure that there is no space or line breaks around the values in your xml file.

这篇关于Magento-致命错误:类名必须是有效对象或字符串的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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