Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/joomla/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
访问joomla';从php文件外部删除帮助程序_Php_Joomla_Libraries_Helpers_Dbo - Fatal编程技术网

访问joomla';从php文件外部删除帮助程序

访问joomla';从php文件外部删除帮助程序,php,joomla,libraries,helpers,dbo,Php,Joomla,Libraries,Helpers,Dbo,我试图从同一服务器上的php文件访问joomla的方法 $shop_directory = '/var/www/components/com_shop'; $base_directory = '/var/www'; define( '_JEXEC', 1 ); define( 'JPATH_BASE', $base_directory); define( 'JPATH_COMPONENT', $shop_directory); define( 'DS', '/' ); require_once

我试图从同一服务器上的php文件访问joomla的方法

$shop_directory = '/var/www/components/com_shop';
$base_directory = '/var/www';

define( '_JEXEC', 1 );
define( 'JPATH_BASE', $base_directory);
define( 'JPATH_COMPONENT', $shop_directory);
define( 'DS', '/' );
require_once(JPATH_COMPONENT.DS.'helpers'.DS.'helpers.php');
require_once(JPATH_COMPONENT.DS.'helpers'.DS.'dbo.php');
require_once(JPATH_BASE.DS.'libraries'.DS.'joomla'.DS.'factory.php');
当我尝试在数据库中插入数据时,什么都没有发生

$db = JFactory::getDbo('database_name');
$query = "INSERT INTO `payment_info` VALUES ( 
                    '',
                    '".$order_id."',
                    '".$customer_id."');";
$db->setQuery($query);
$db->query();
Thx

试试这个

define( '_JEXEC', 1 );
define('JPATH_BASE', dirname(__FILE__) );//this is when we are in the 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');
$mainframe->initialise();

$db = JFactory::getDbo();//Db object do not require database name
$query = "INSERT INTO `payment_info` VALUES ( 

                    '".$order_id."',
                    '".$customer_id."')";
$db->setQuery($query);
$db->query();

希望它的作品..

define('JPATH_BASE',dirname(FILE));正确设置路径必须设置的路径是Joomla安装,例如:此php页面位于根目录下,Joomla安装也位于根目录下,然后与上面的代码完全相同。其他方面,您必须根据Joomla安装调整路径。它会起作用的