From 9f71c9e713d38e087f6eb6f1e776441dd20a5aee Mon Sep 17 00:00:00 2001 From: moodler Date: Fri, 9 May 2003 02:20:03 +0000 Subject: [PATCH] Use the new $CFG->dbpersist variable in config.php to determine whether to use persistent connections or not. The default is to use them (for speed/efficiency) but now they can be switched off with: $CFG->dbpersist = false; --- lib/setup.php | 31 +++++++++++++++++++------------ 1 file changed, 19 insertions(+), 12 deletions(-) diff --git a/lib/setup.php b/lib/setup.php index 34b8875a5a..011bbde045 100644 --- a/lib/setup.php +++ b/lib/setup.php @@ -22,19 +22,26 @@ $db = &ADONewConnection($CFG->dbtype); error_reporting(0); // Hide errors - // 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)) { - 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->dbpersist) or !empty($CFG->dbpersist)) { // Use persistent connection (default) + $dbconnected = $db->PConnect($CFG->dbhost,$CFG->dbuser,$CFG->dbpass,$CFG->dbname); + } else { // Use single connection + $dbconnected = $db->Connect($CFG->dbhost,$CFG->dbuser,$CFG->dbpass,$CFG->dbname); + } + if (! $dbconnected) { + echo ""; + echo "

Error: Moodle could not connect to the database.

"; + echo "

It's possible the database itself is just not working at the moment.

"; + echo "

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
"; + if (!isset($CFG->dbpersist)) { + echo "

The admin should also try setting this in config.php: $"."CFG->dbpersist = false;

"; } + echo "
"; + die; } error_reporting(E_ALL); // Show errors from now on. -- 2.39.5