对于joomla 1.5我使用下面的代码行来获取数据库对象,但joomla 2.5的等效代码是什么?我使用了很多代码,但似乎都没有工作,包括在stackoverflow本身上找到...所有我想通过Ajax调用php脚本来通过DB更新下拉列表...并且我得到错误500:内部服务器错误
// joomla 1.5 code
define( '_JEXEC', 1 );
define( 'DS', DIRECTORY_SEPARATOR );
define( 'JPATH_BASE', $_SERVER[ 'DOCUMENT_ROOT' ] );
require_once( JPATH_BASE . DS . 'includes' . DS . 'defines.php' );
require_once( JPATH_BASE . DS . 'includes' . DS . 'framework.php' );
require_once( JPATH_BASE . DS . 'libraries' . DS . 'joomla' . DS . 'factory.php' );
$mainframe =& JFactory::getApplication('site');
$get_db = &JFactory::getDBO();
我的脚本文件,我通过ajax调用它有以下代码...它仍然响应内部服务器错误,不知道包含oor常量的错误,如果我删除除了最后一行之外的所有行,这工作正常,'嗨'由ajax调用返回...即时通讯使用joomla 2.5.7,任何提示???
//joomla 2.5 script NOT WORKING
define( '_JEXEC' 1 );
define( '_VALID_MOS' 1 );
define( 'JPATH_BASE' realpath(dirname(__FILE__)));
define( 'DS' DIRECTORY_SEPARATOR );
require_once ( JPATH_BASE .DS.'includes'.DS.'defines.php' );
require_once ( JPATH_BASE .DS.'includes'.DS.'framework.php' );
echo JPATH_BASE .DS.'includes'.DS.'framework.php';
$mainframe =& JFactory::getApplication('site');
$mainframe->initialise();
echo $mainframe->getCfg('sitename');
$db =& JFactory::getDBO();
echo "hi";
答案 0 :(得分:0)
以下是我用来从shell脚本访问Joomlas数据库的代码:
define('_JEXEC', 1);
define('DS', DIRECTORY_SEPARATOR);
if (!defined('_JDEFINES')) {
define('JPATH_BASE', dirname(__FILE__));
require_once JPATH_BASE.'/includes/defines.php';
}
require_once JPATH_BASE.'/includes/framework.php';
// Mark afterLoad in the profiler.
JDEBUG ? $_PROFILER->mark('afterLoad') : null;
// Instantiate the application.
$app = JFactory::getApplication('site');
// Initialise the application.
$app->initialise();
$dbo = JFactory::getDBO();