mirror of
https://github.com/dg/dibi.git
synced 2025-08-06 06:07:39 +02:00
Disconnect on not connected driver not fail (#222)
Sometimes database go away and Connection::isConnected() is returning TRUE. Prevent this should be posibble to disconnect on closed connection without error.
This commit is contained in:
@@ -96,7 +96,7 @@ class FirebirdDriver implements Dibi\Driver, Dibi\ResultDriver, Dibi\Reflector
|
||||
*/
|
||||
public function disconnect()
|
||||
{
|
||||
ibase_close($this->connection);
|
||||
@ibase_close($this->connection); // @ - connection can be already disconnected
|
||||
}
|
||||
|
||||
|
||||
|
@@ -78,7 +78,7 @@ class MsSqlDriver implements Dibi\Driver, Dibi\ResultDriver
|
||||
*/
|
||||
public function disconnect()
|
||||
{
|
||||
mssql_close($this->connection);
|
||||
@mssql_close($this->connection); // @ - connection can be already disconnected
|
||||
}
|
||||
|
||||
|
||||
|
@@ -139,7 +139,7 @@ class MySqlDriver implements Dibi\Driver, Dibi\ResultDriver
|
||||
*/
|
||||
public function disconnect()
|
||||
{
|
||||
mysql_close($this->connection);
|
||||
@mysql_close($this->connection); // @ - connection can be already disconnected
|
||||
}
|
||||
|
||||
|
||||
|
@@ -138,7 +138,7 @@ class MySqliDriver implements Dibi\Driver, Dibi\ResultDriver
|
||||
*/
|
||||
public function disconnect()
|
||||
{
|
||||
mysqli_close($this->connection);
|
||||
@mysqli_close($this->connection); // @ - connection can be already disconnected
|
||||
}
|
||||
|
||||
|
||||
|
@@ -88,7 +88,7 @@ class OdbcDriver implements Dibi\Driver, Dibi\ResultDriver, Dibi\Reflector
|
||||
*/
|
||||
public function disconnect()
|
||||
{
|
||||
odbc_close($this->connection);
|
||||
@odbc_close($this->connection); // @ - connection can be already disconnected
|
||||
}
|
||||
|
||||
|
||||
|
@@ -95,7 +95,7 @@ class OracleDriver implements Dibi\Driver, Dibi\ResultDriver, Dibi\Reflector
|
||||
*/
|
||||
public function disconnect()
|
||||
{
|
||||
oci_close($this->connection);
|
||||
@oci_close($this->connection); // @ - connection can be already disconnected
|
||||
}
|
||||
|
||||
|
||||
|
@@ -111,7 +111,7 @@ class PostgreDriver implements Dibi\Driver, Dibi\ResultDriver, Dibi\Reflector
|
||||
*/
|
||||
public function disconnect()
|
||||
{
|
||||
pg_close($this->connection);
|
||||
@pg_close($this->connection); // @ - connection can be already disconnected
|
||||
}
|
||||
|
||||
|
||||
|
@@ -99,7 +99,7 @@ class SqlsrvDriver implements Dibi\Driver, Dibi\ResultDriver
|
||||
*/
|
||||
public function disconnect()
|
||||
{
|
||||
sqlsrv_close($this->connection);
|
||||
@sqlsrv_close($this->connection); // @ - connection can be already disconnected
|
||||
}
|
||||
|
||||
|
||||
|
@@ -36,3 +36,15 @@ test(function () use ($config) { // query string
|
||||
Assert::same($config['driver'], $conn->getConfig('driver'));
|
||||
Assert::type('Dibi\Driver', $conn->getDriver());
|
||||
});
|
||||
|
||||
|
||||
test(function () use ($config) {
|
||||
$conn = new Connection($config);
|
||||
Assert::true($conn->isConnected());
|
||||
|
||||
$conn->disconnect();
|
||||
Assert::false($conn->isConnected());
|
||||
|
||||
$conn->disconnect();
|
||||
Assert::false($conn->isConnected());
|
||||
});
|
||||
|
Reference in New Issue
Block a user