Commit 240a4fd5 authored by Alexander Butenko's avatar Alexander Butenko Committed by GitHub

Merge pull request #608 from avbdr/master

Added a function to disconnect from mysql server
parents b6545106 90f26fb2
...@@ -289,6 +289,20 @@ class MysqliDb ...@@ -289,6 +289,20 @@ class MysqliDb
} }
} }
/**
* A method to disconnect from the database
*
* @throws Exception
* @return void
*/
public function disconnect()
{
if (!$this->_mysqli)
return;
$this->_mysqli->close();
$this->_mysqli = null;
}
/** /**
* A method to get mysqli object or create it in case needed * A method to get mysqli object or create it in case needed
* *
......
...@@ -699,6 +699,11 @@ if($db->has("users")) { ...@@ -699,6 +699,11 @@ if($db->has("users")) {
} }
``` ```
### Helper methods ### Helper methods
Disconnect from the database:
```php
$db->disconnect();
```
Reconnect in case mysql connection died: Reconnect in case mysql connection died:
```php ```php
if (!$db->ping()) if (!$db->ping())
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment