Merge pull request #7428 from burriko/fix-dbo-connection-issues

Fix use of $_connection in DboSource in 2.x
This commit is contained in:
Mark Story 2015-09-21 21:38:20 -04:00
commit 9208a0857e

View file

@ -284,7 +284,7 @@ class DboSource extends DataSource {
if ($this->_result instanceof PDOStatement) { if ($this->_result instanceof PDOStatement) {
$this->_result->closeCursor(); $this->_result->closeCursor();
} }
unset($this->_connection); $this->_connection = null;
$this->connected = false; $this->connected = false;
return true; return true;
} }
@ -857,10 +857,14 @@ class DboSource extends DataSource {
* @return bool True if the database is connected, else false * @return bool True if the database is connected, else false
*/ */
public function isConnected() { public function isConnected() {
try { if ($this->_connection === null) {
$connected = $this->_connection->query('SELECT 1');
} catch (Exception $e) {
$connected = false; $connected = false;
} else {
try {
$connected = $this->_connection->query('SELECT 1');
} catch (Exception $e) {
$connected = false;
}
} }
$this->connected = !empty($connected); $this->connected = !empty($connected);
return $this->connected; return $this->connected;