Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions wire/core/WireDatabasePDO.php
Original file line number Diff line number Diff line change
Expand Up @@ -319,6 +319,21 @@ public function __get($key) {
public function closeConnection() {
$this->pdo = null;
}

/**
* Tries to query the db and if it fails tries to reconnect
* @return boolean
*/
public function ping() {
try {
$this->pdo->query('SELECT 1');
} catch (PDOException $e) {
//force reconnect
$this->closeConnection();
$this->pdo();
}
return true;
}

/**
* Retrieve new instance of WireDatabaseBackups ready to use with this connection
Expand Down Expand Up @@ -346,3 +361,4 @@ public function backups() {
}

}