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

查看:102
本文介绍了要连接到Joomla中的第三方数据库吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要连接到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!.已在其服务器上的自己的数据库上安装并运行,但是我想连接到另一个数据库(当前数据库的ON TOP)以提取一些数据,然后从该第3方数据库断开连接-所有这些都保持了原始的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 DB的当前资源. 试试这个:

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

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