在 Joomla 中连接到第 3 方数据库? [英] Connecting to 3rd party database in Joomla?

查看:21
本文介绍了在 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 方数据库?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆