Configuring a connection to a second database on the server

Permalink
Hi,

I have an additional database, which I've built before stumbling upon C5. What file am I editing to configure the connection to this database?

Also, when building my pages, I'd like to avoid adding the database configuration in each custom php block. So what file am I editing so that this configuration is called upon for the whole page?

 
goutnet replied on at Permalink Reply
You can install concrete5 directly in that database, just make sure that your preceding tables are prefixed so that they won't collide with Concrete5.

Or, if you specifically want to have a second database, you can add a global setting in concrete5 to store the connection string, and use it to setup your own ADODB connection with that.

Get/set config :

// $pkg must contain the Package object
$pkg->saveConfig( 'mydburl', 'mysql://user:pass@myhost/db' );
$url = $pkg->config('mydburl');


create an adodb connection :

$db = @NewADOConnection($url);


check the Loader::db to know how to create a db Connection with ADODB

you could just put that code in your package, so you would only have to call it back.