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) {
|
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;
|
||||||
|
|
Loading…
Reference in a new issue