suppress access on null php notice in new is_connected method (#7228)
This commit is contained in:
parent
5ef71889fe
commit
ba1dc820eb
|
|
@ -2948,7 +2948,7 @@
|
||||||
return $this->message;
|
return $this->message;
|
||||||
} //save method
|
} //save method
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Ensure the database is still connected and active.
|
* Ensure the database is still connected and active.
|
||||||
* <p>NOTE:<br>
|
* <p>NOTE:<br>
|
||||||
* There is no method in PDO that can reliably detect if the connection is active. Therefor, a lightweight
|
* There is no method in PDO that can reliably detect if the connection is active. Therefor, a lightweight
|
||||||
|
|
@ -2957,7 +2957,8 @@
|
||||||
*/
|
*/
|
||||||
public function is_connected(): bool {
|
public function is_connected(): bool {
|
||||||
try {
|
try {
|
||||||
$stmt = $this->db->query('SELECT 1');
|
$stmt = false;
|
||||||
|
if ($this->db !== null) $stmt = $this->db->query('SELECT 1');
|
||||||
return $stmt !== false;
|
return $stmt !== false;
|
||||||
} catch (PDOException $ex) {
|
} catch (PDOException $ex) {
|
||||||
//database is not connected
|
//database is not connected
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue