CMS Made Simple Forums
https://forum.cmsmadesimple.org/

How to connect to a second database
https://forum.cmsmadesimple.org/viewtopic.php?f=28&t=81321
Page 1 of 1

Author:  jagro [ Wed Jul 17, 2019 7:44 am ]
Post subject:  How to connect to a second database

I want to use data from an alternative database in a UDT in CMSMS 2.2.10.

I have tried to connect it like this:
\$1:
$alternativedb = array();
$alternativedbhost = '***';
$alternativedbuser = '***';
$alternativedbpswd = '***';
$alternativedbdbsn = '***';
$alternativedb = ADONewConnection('mysqli', 'pear:date:extend');
$alternativedb->Connect($alternativedbhost,$alternativedbuser,$alternativedbpswd,$alternativedbdbsn);
print_r($alternativedb);

However, the printed variable shows the information of the CMSMS database.

How can I connect to the other database?

Author:  calguy1000 [ Wed Jul 17, 2019 11:57 am ]
Post subject:  Re: How to connect to a second database

use \CMSMS\Database\Connection::Initialize();
you must provide it a \CMSSM\Database\ConnectionSpec object with your connection details.

Author:  jagro [ Wed Jul 17, 2019 12:23 pm ]
Post subject:  Re: How to connect to a second database

Thank you Robert, this is what I needed.

Page 1 of 1 All times are UTC
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
http://www.phpbb.com/