Check $_connection is not null before trying to use it

Stops a fatal error if calling isConnected() after disconnect().
This commit is contained in:
Graeme Tait 2015-09-21 14:08:07 +01:00
parent 8fae10a971
commit 1b33efaad3

View file

@ -857,11 +857,15 @@ class DboSource extends DataSource {
* @return bool True if the database is connected, else false
*/
public function isConnected() {
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;
}