Connecting to 3rd party database in Joomla?(在 Joomla 中连接到第 3 方数据库?)
问题描述
我需要连接到 Joomla 中的另一个数据库!那是在另一台服务器上.这是一个插件,我需要从表中提取一些数据.
I need to connect to another database in Joomla! that's on another server. This is for a plugin and I need to pull some data from a table.
现在我不想用这个数据库来运行Joomla!,我已经有了Joomla!在其服务器上的自己的数据库上安装并运行,但我想连接到另一个数据库(在当前数据库的顶部)以提取一些数据,然后与该 3rd 方数据库断开连接 - 同时保持原始 Joomla 数据库连接正常.
Now what I don't want is to use this database to run Joomla!, I already have Joomla! installed and running on its own database on its server but I want to connect to another database (ON TOP of the current one) to pull some data, then disconnect from that 3rd party database - all while keeping the original Joomla database connection in tact.
推荐答案
您可以从 joomla 实例连接到外部数据库,而无需使用 joomla 数据库的当前资源.试试这个:
You can connect to an external database from your joomla instance without using the current ressource of your joomla DB. Try this:
<?php
$option = array(); //prevent problems
$option['driver'] = 'mysql';
$option['host'] = 'dbase.host.com';
$option['user'] = 'login';
$option['password'] = 'pwd';
$option['database'] = 'anotherdb';
$db = & JDatabase::getInstance( $option );
?>
有关这方面的更多信息,请查看 Joomla!文档
For more infromations regarding this, check the Joomla! Documentation
这篇关于在 Joomla 中连接到第 3 方数据库?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:在 Joomla 中连接到第 3 方数据库?


- Mod使用GET变量将子域重写为PHP 2021-01-01
- 带有通配符的 Laravel 验证器 2021-01-01
- PHP Count 布尔数组中真值的数量 2021-01-01
- SoapClient 设置自定义 HTTP Header 2021-01-01
- Laravel 仓库 2022-01-01
- 正确分离 PHP 中的逻辑/样式 2021-01-01
- 没有作曲家的 PSR4 自动加载 2022-01-01
- 从 PHP 中的输入表单获取日期 2022-01-01
- Oracle 即时客户端 DYLD_LIBRARY_PATH 错误 2022-01-01
- 如何定位 php.ini 文件 (xampp) 2022-01-01