BoincDb::get():

if open to different dbnum, close and reconnect.
Don't throw exception if connect fails
This commit is contained in:
David Anderson 2024-08-17 12:17:25 -07:00
parent 4b4ba9dbf8
commit da1727c64f
2 changed files with 8 additions and 9 deletions

View File

@ -105,7 +105,10 @@ class BoincDb {
static function get($dbnum = 0) {
global $generating_xml;
if (isset(self::$instance)) {
return self::$instance;
if (self::$dbnum == $dbnum) {
return self::$instance;
}
close();
}
if (web_stopped()) {
if ($generating_xml) {

View File

@ -33,14 +33,10 @@ class DbConn {
} else {
$port = null;
}
if (1) { // don't use persistent connections for now
$this->db_conn = @new mysqli(
$host, $user, $passwd, $name, $port
);
} else {
$this->db_conn = @new mysqli(
'p:'.$host, $user, $passwd, $name, $port
);
try {
$this->db_conn = @new mysqli($host, $user, $passwd, $name, $port);
} catch(Exception $e) {
return false;
}
if (mysqli_connect_error()) {
return false;