mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2024-11-15 03:18:26 +00:00
DboSource now check the actual status of connection by executing a dumb query on DB
This change makes it possible for developer to build reconnection logic on MySQL connections which frequently time out in long running CLI processes. Cherry picked onto 2.7 from #7190.
This commit is contained in:
parent
f959b76013
commit
a7b5f8c3af
1 changed files with 6 additions and 0 deletions
|
@ -857,6 +857,12 @@ 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) {
|
||||
$connected = false;
|
||||
}
|
||||
$this->connected = ! empty($connected);
|
||||
return $this->connected;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue