mirror of
https://github.com/moodle/moodle.git
synced 2025-08-04 16:36:37 +02:00
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;
This commit is contained in:
parent
6c8e8b5ed4
commit
9f71c9e713
1 changed files with 19 additions and 12 deletions
|
@ -22,20 +22,27 @@
|
||||||
$db = &ADONewConnection($CFG->dbtype);
|
$db = &ADONewConnection($CFG->dbtype);
|
||||||
|
|
||||||
error_reporting(0); // Hide errors
|
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 (!isset($CFG->dbpersist) or !empty($CFG->dbpersist)) { // Use persistent connection (default)
|
||||||
if (! $db->Connect($CFG->dbhost,$CFG->dbuser,$CFG->dbpass,$CFG->dbname)) {
|
$dbconnected = $db->PConnect($CFG->dbhost,$CFG->dbuser,$CFG->dbpass,$CFG->dbname);
|
||||||
echo "<font color=red>";
|
} 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>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
|
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>";
|
also check that the database details have been correctly specified in config.php</p>";
|
||||||
echo "<p>Database host: $CFG->dbhost<br />";
|
echo "<p>Database host: $CFG->dbhost<br />";
|
||||||
echo "Database name: $CFG->dbname<br />";
|
echo "Database name: $CFG->dbname<br />";
|
||||||
echo "Database user: $CFG->dbuser<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>";
|
echo "</font>";
|
||||||
die;
|
die;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
error_reporting(E_ALL); // Show errors from now on.
|
error_reporting(E_ALL); // Show errors from now on.
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue