]> git.mjollnir.org Git - moodle.git/commitdiff
Use the new $CFG->dbpersist variable in config.php to determine whether
authormoodler <moodler>
Fri, 9 May 2003 02:20:03 +0000 (02:20 +0000)
committermoodler <moodler>
Fri, 9 May 2003 02:20:03 +0000 (02:20 +0000)
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

index 34b8875a5af4346f27963eb64b66049bb681f268..011bbde045b811e888cf6fbd7bc190e696d93a06 100644 (file)
     $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 "<font color=red>";
-            echo "<p>Error: Moodle could not connect to the database.</p>";
-            echo "<p>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</p>";
-            echo "<p>Database host: $CFG->dbhost<br />";
-            echo "Database name: $CFG->dbname<br />";
-            echo "Database user: $CFG->dbuser<br />";
-            echo "</font>";
-            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 "<font color=\"#990000\">";
+        echo "<p>Error: Moodle could not connect to the database.</p>";
+        echo "<p>It's possible the database itself is just not working at the moment.</p>";
+        echo "<p>The admin should 
+                 also check that the database details have been correctly specified in config.php</p>";
+        echo "<p>Database host: $CFG->dbhost<br />";
+        echo "Database name: $CFG->dbname<br />";
+        echo "Database user: $CFG->dbuser<br />";
+        if (!isset($CFG->dbpersist)) {
+            echo "<p>The admin should also try setting this in config.php:  $"."CFG->dbpersist = false; </p>";
         }
+        echo "</font>";
+        die;
     }
 
     error_reporting(E_ALL);       // Show errors from now on.