栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 面试经验 > 面试问答

在外部php文件Joomla中包含Jfactory类

面试问答 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

在外部php文件Joomla中包含Jfactory类

我敢肯定您会发现,但也许对其他人有用

要使用joomla数据库类(即使您不建议使用:)),也需要先定义三个常量,例如:

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

编辑

您只能包含两个文件,例如:

define( 'JPATH_base', $_SERVER[ 'document_ROOT' ] ); // define JPATH_base on the external filerequire_once( JPATH_base . DS . 'libraries' . DS . 'import.php' ); // frameworkrequire_once( JPATH_base . DS . 'configuration.php' ); // config file

最后使用joomla类,例如:

$db = JFactory::getDBO();


转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/421355.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号