首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >致命错误:找不到类'JDatabaseDriver‘

致命错误:找不到类'JDatabaseDriver‘
EN

Stack Overflow用户
提问于 2016-02-02 02:46:32
回答 1查看 839关注 0票数 0
代码语言:javascript
运行
复制
Fatal error: Class 'JDatabaseDriver' not found in /home/jensen/public_html/libraries/joomla/factory.php on line 631

我已经在网上搜索这个问题的答案两天了,我在joomla论坛上花了很多时间,但我没有找到任何解决这个问题的东西。希望我能在这里得到一些方向。

当我转到网站http://jensenlocksmithing.com时,出现此错误

但是,如果我键入http:/jensenlocksmithing.com/index.php,错误再次消失。这对我来说真的很奇怪。

下面是错误所指的代码块:

/** *创建数据库对象** @return JDatabaseDriver **@查看JDatabaseDriver *@从11.1开始*/受保护的静态函数createDbo() { $conf = self::getConfig();

代码语言:javascript
运行
复制
    $host = $conf->get('host');
    $user = $conf->get('user');
    $password = $conf->get('password');
    $database = $conf->get('db');
    $prefix = $conf->get('dbprefix');
    $driver = $conf->get('dbtype');
    $debug = $conf->get('debug');

    $options = array('driver' => $driver, 'host' => $host, 'user' => $user, 'password' => $password, 'database' => $database, 'prefix' => $prefix);

    try
    {
        $db = JDatabaseDriver::getInstance($options);
    }
    catch (RuntimeException $e)
    {
        if (!headers_sent())
        {
            header('HTTP/1.1 500 Internal Server Error');
        }

        jexit('Database Error: ' . $e->getMessage());
    }

    $db->setDebug($debug);

    return $db;
}

我已经尝试完全重新安装joomla安装来解决这个问题,之后我清除了缓存,但我仍然收到错误。

任何建议都会很有帮助。

EN

回答 1

Stack Overflow用户

发布于 2016-02-02 08:55:09

下面的代码应该可以工作,这是我在我的铜矿图片库图像模块中使用的代码:

代码语言:javascript
运行
复制
$config = JFactory::getConfig();
$option = array();
$option['driver']   = $config->get('dbtype');
$option['host']     = $config->get('host');
$option['user']     = $config->get('user');
$option['password'] = $config->get('password');
$option['database'] = $config->get('db');
$option['prefix']   = $config->get('dbprefix');

//UNCOMMENT THE FOLLOWING LINE TO VIEW OPTIONS ARRAY CONTENTS         
//print_r($option);

$db = JFactory::getDBO();
try
{
    $db = JDatabase::getInstance($option);
}
catch (RuntimeException $e)
{
    JFactory::getApplication()->enqueueMessage($e->getMessage());
    $db->setDebug($debug);
    return false;
}
return $db;

希望这能解决你的问题。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/35137979

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档