Index: PGConnection.h ================================================================== --- PGConnection.h +++ PGConnection.h @@ -16,14 +16,15 @@ - (void)setParameters: (OFDictionary*)parameters; - (OFDictionary*)parameters; - (void)connect; - (void)reset; +- (void)close; - (PGResult*)executeCommand: (OFConstantString*)command; - (PGResult*)executeCommand: (OFConstantString*)command parameters: (id)firstParameter, ... OF_SENTINEL; - (PGconn*)PG_connection; - (void)insertRow: (OFDictionary*)row intoTable: (OFString*)table; - (void)insertRows: (OFArray*)rows intoTable: (OFString*)table; @end Index: PGConnection.m ================================================================== --- PGConnection.m +++ PGConnection.m @@ -6,12 +6,11 @@ @implementation PGConnection - (void)dealloc { [_parameters release]; - if (_connnection != NULL) - PQfinish(_connnection); + [self close]; [super dealloc]; } - (void)setParameters: (OFDictionary*)parameters @@ -55,10 +54,18 @@ - (void)reset { PQreset(_connnection); } + +- (void)close +{ + if (_connnection != NULL) + PQfinish(_connnection); + + _connnection = NULL; +} - (PGResult*)executeCommand: (OFConstantString*)command { PGresult *result = PQexec(_connnection, [command UTF8String]);