JFactory,JDatabase class not found in /var/www/joomla2.5/database.php

て烟熏妆下的殇ゞ 提交于 2019-12-11 15:47:36

问题


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();

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 );
?> 

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

I am using joomla2.5 and Ubuntu12.04 OS

need help...


回答1:


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');


来源:https://stackoverflow.com/questions/17939546/jfactory-jdatabase-class-not-found-in-var-www-joomla2-5-database-php

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!