From 4f5dbd132c47e0d59bf854ae2110215cd36c72c1 Mon Sep 17 00:00:00 2001 From: moodler Date: Wed, 7 May 2003 08:03:43 +0000 Subject: [PATCH] Try persistent connection first, but if that fails for some reason then automatically fall back to a non-persistent connection. --- lib/setup.php | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/lib/setup.php b/lib/setup.php index 3f85bc6477..da5f28dfd3 100644 --- a/lib/setup.php +++ b/lib/setup.php @@ -21,9 +21,19 @@ $db = &ADONewConnection($CFG->dbtype); + // Try a persistent connection first, but if it fails, fall back to ordinary connection if (! $db->PConnect($CFG->dbhost,$CFG->dbuser,$CFG->dbpass,$CFG->dbname)) { - echo "

The database details specified in config.php are not correct, or the database is down.

"; - die; + if (! $db->Connect($CFG->dbhost,$CFG->dbuser,$CFG->dbpass,$CFG->dbname)) { + echo ""; + echo "

Error: Moodle could not connect to the database.

"; + echo "

It's possible the database itself is not working at the moment, but the admin should + also check that the database details have been correctly specified in config.php

"; + echo "

Database host: $CFG->dbhost
"; + echo "Database name: $CFG->dbname
"; + echo "Database user: $CFG->dbuser
"; + echo "
"; + die; + } } if (!isset($CFG->prefix)) { // Just in case it isn't defined in config.php -- 2.39.5