diff --git a/PGConnection.h b/PGConnection.h index 3c9bd42..d314266 100644 --- a/PGConnection.h +++ b/PGConnection.h @@ -18,6 +18,7 @@ - (OFDictionary*)parameters; - (void)connect; - (void)reset; +- (void)close; - (PGResult*)executeCommand: (OFConstantString*)command; - (PGResult*)executeCommand: (OFConstantString*)command parameters: (id)firstParameter, ... OF_SENTINEL; diff --git a/PGConnection.m b/PGConnection.m index ebdba94..60d8c3c 100644 --- a/PGConnection.m +++ b/PGConnection.m @@ -8,8 +8,7 @@ { [_parameters release]; - if (_connnection != NULL) - PQfinish(_connnection); + [self close]; [super dealloc]; } @@ -58,6 +57,14 @@ PQreset(_connnection); } +- (void)close +{ + if (_connnection != NULL) + PQfinish(_connnection); + + _connnection = NULL; +} + - (PGResult*)executeCommand: (OFConstantString*)command { PGresult *result = PQexec(_connnection, [command UTF8String]);