mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2024-11-15 03:18:26 +00:00
Merge pull request #7428 from burriko/fix-dbo-connection-issues
Fix use of $_connection in DboSource in 2.x
This commit is contained in:
commit
9208a0857e
1 changed files with 8 additions and 4 deletions
|
@ -284,7 +284,7 @@ class DboSource extends DataSource {
|
|||
if ($this->_result instanceof PDOStatement) {
|
||||
$this->_result->closeCursor();
|
||||
}
|
||||
unset($this->_connection);
|
||||
$this->_connection = null;
|
||||
$this->connected = false;
|
||||
return true;
|
||||
}
|
||||
|
@ -857,11 +857,15 @@ class DboSource extends DataSource {
|
|||
* @return bool True if the database is connected, else false
|
||||
*/
|
||||
public function isConnected() {
|
||||
if ($this->_connection === null) {
|
||||
$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