mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2024-11-15 03:18:26 +00:00
Check $_connection is not null before trying to use it
Stops a fatal error if calling isConnected() after disconnect().
This commit is contained in:
parent
8fae10a971
commit
1b33efaad3
1 changed files with 7 additions and 3 deletions
|
@ -857,10 +857,14 @@ class DboSource extends DataSource {
|
|||
* @return bool True if the database is connected, else false
|
||||
*/
|
||||
public function isConnected() {
|
||||
try {
|
||||
$connected = $this->_connection->query('SELECT 1');
|
||||
} catch (Exception $e) {
|
||||
if (is_null($this->_connection)) {
|
||||
$connected = false;
|
||||
} else {
|
||||
try {
|
||||
$connected = $this->_connection->query('SELECT 1');
|
||||
} catch (Exception $e) {
|
||||
$connected = false;
|
||||
}
|
||||
}
|
||||
$this->connected = ! empty($connected);
|
||||
return $this->connected;
|
||||
|
|
Loading…
Reference in a new issue