Hello everyone.
Anybody can help me with the following?. I need to connect modx with a database, but if this connection fail, then connect to another.
Is this possible? How can I make this? Where can I find information about modx’s source code?
Thank you.
-
☆ A M B ☆
- 24,524 Posts
If you are talking about the database MODx itself uses, then it makes its connection on line 1040 of manager/includes/document.parser.class.inc.php
The db API function it uses is at line 80 of manager/includes/extender/db.mysql.class.inc.php
I resolved this topic modify the file manager->include->config.inc.php like this
$database_type = ’mysql’;
$database_server = ’localhost’;
$database_user = ’user’;
$database_password = ’password’;
$link = mysql_connect($database_server, $database_user, $database_password);
// connect to the database
if(!$link) {
$database_server = ’192.168.0.22’;
$database_user = ’user’;
$database_password = ’password’;
}
else
mysql_close($link);
And remember allow external connections for the second database.
That is a great idea! Cool!