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 * * @see JDatabaseDriver * @since 11.1 */ 受保护的静态函数创建Dbo() { $conf = self::getConfig();
$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安装以解决问题,之后我清除了缓存,但仍然收到错误。
任何建议都会有所帮助。
以下代码应该有效,这是我在铜矿照片库图像模块中使用的代码:
$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;
希望这能解决您的问题。