Commit 90f26fb2 authored by Alexander Butenko's avatar Alexander Butenko

Added a function to disconnect from mysql server

parent b6545106
......@@ -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
*
......
......@@ -699,6 +699,11 @@ if($db->has("users")) {
}
```
### Helper methods
Disconnect from the database:
```php
$db->disconnect();
```
Reconnect in case mysql connection died:
```php
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