- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
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,错误就会再次消失。这对我来说真的很奇怪。
这是错误引用的代码块:
/** * 创建数据库对象 * * @返回JDatabaseDriver * * @see JDatabaseDriver * @自 11.1 起 */ protected 静态函数createDbo() { $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 安装来解决该问题,之后我清除了缓存,但仍然收到错误。
任何建议都会有帮助。
最佳答案
以下代码应该可以工作,这是我在 Coppermine 照片库图像模块中使用的代码:
$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;
希望这能解决您的问题。
关于php - fatal error : Class 'JDatabaseDriver' not found,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35137979/
我正在尝试使用以下代码通过 Joomla 连接到外部数据库: $option = array(); //prevent problems $option['driver
Fatal error: Class 'JDatabaseDriver' not found in /home/jensen/public_html/libraries/joomla/factory.
我是一名优秀的程序员,十分优秀!