php中找不到JFactory

php中找不到JFactory

本文介绍了在/var/www/joomla2.5/database.php中找不到JFactory,JDatabase类的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试建立与数据库的连接,但出现错误JFactory类,但找不到/var/www/joomla2.5/database.php,我的代码是

I am trying to make connection to my data base but i am getting error JFactory class not found /var/www/joomla2.5/database.php my code is

$db= JFactory::getDBO();

我也尝试过从外部建立数据库连接,但是后来我发现找不到JDatabase类错误

I have also tried to make database connection externally but then iam getting the error JDatabase class not found

<?php
$option = array(); //prevent problems

$option['driver']   = 'mysql';
$option['host']     = 'localhost';
$option['user']     = 'xxxx';
$option['password'] = 'xxxx';
$option['database'] = 'xxxx';
$option['prefix']   = 'cdri_';

$db = & JDatabase::getInstance( $option );
?>

我已经检查了factory.php文件,其中定义了抽象的JFactory类.

I have checked my factory.php file it has a abstract JFactory class defined.

我正在使用joomla2.5和Ubuntu12.04 OS

I am using joomla2.5 and Ubuntu12.04 OS

需要帮助...

推荐答案

仅将文件放在joomla文件夹中并不能访问joomla库.使其成为标准的joomla组件或模块,或者将以下代码添加到您的php文件中

Just putting a file inside joomla folder doesn't gave it access to joomla libraries.Either make it as standard joomla component or module or add follwing code to your php file

define( '_JEXEC', 1 );
define('JPATH_BASE', dirname(__FILE__).'/' );   // should point to joomla root
define( 'DS', DIRECTORY_SEPARATOR );
require_once ( JPATH_BASE .DS.'includes'.DS.'defines.php' );
require_once ( JPATH_BASE .DS.'includes'.DS.'framework.php' );
$mainframe = JFactory::getApplication('site');

这篇关于在/var/www/joomla2.5/database.php中找不到JFactory,JDatabase类的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-15 06:05