@@ -4,65 +4,65 @@ #import "PGCommandFailedException.h" @implementation PGConnection - (void)dealloc { - [parameters release]; + [_parameters release]; - if (conn != NULL) - PQfinish(conn); + if (_connnection != NULL) + PQfinish(_connnection); [super dealloc]; } -- (void)setParameters: (OFDictionary*)parameters_ +- (void)setParameters: (OFDictionary*)parameters { - OF_SETTER(parameters, parameters_, YES, YES) + OF_SETTER(_parameters, parameters, YES, YES) } - (OFDictionary*)parameters { - OF_GETTER(parameters, YES) + OF_GETTER(_parameters, YES) } - (void)connect { OFAutoreleasePool *pool = [[OFAutoreleasePool alloc] init]; - OFEnumerator *keyEnumerator = [parameters keyEnumerator]; - OFEnumerator *objectEnumerator = [parameters objectEnumerator]; - OFMutableString *conninfo = nil; + OFEnumerator *keyEnumerator = [_parameters keyEnumerator]; + OFEnumerator *objectEnumerator = [_parameters objectEnumerator]; + OFMutableString *connectionInfo = nil; OFString *key, *object; while ((key = [keyEnumerator nextObject]) != nil && (object = [objectEnumerator nextObject]) != nil) { - if (conninfo != nil) - [conninfo appendFormat: @" %@=%@", key, object]; + if (connectionInfo != nil) + [connectionInfo appendFormat: @" %@=%@", key, object]; else - conninfo = [OFMutableString stringWithFormat: + connectionInfo = [OFMutableString stringWithFormat: @"%@=%@", key, object]; } - if ((conn = PQconnectdb([conninfo UTF8String])) == NULL) + if ((_connnection = PQconnectdb([connectionInfo UTF8String])) == NULL) @throw [OFOutOfMemoryException exceptionWithClass: [self class]]; - if (PQstatus(conn) == CONNECTION_BAD) + if (PQstatus(_connnection) == CONNECTION_BAD) @throw [PGConnectionFailedException exceptionWithClass: [self class] connection: self]; [pool release]; } - (void)reset { - PQreset(conn); + PQreset(_connnection); } - (PGResult*)executeCommand: (OFConstantString*)command { - PGresult *result = PQexec(conn, [command UTF8String]); + PGresult *result = PQexec(_connnection, [command UTF8String]); if (PQresultStatus(result) == PGRES_FATAL_ERROR) { PQclear(result); @throw [PGCommandFailedException exceptionWithClass: [self class] @@ -125,11 +125,11 @@ else values[i++] = [[parameter description] UTF8String]; } while ((parameter = va_arg(args, id)) != nil); - result = PQexecParams(conn, [command UTF8String], + result = PQexecParams(_connnection, [command UTF8String], argsCount, NULL, values, NULL, NULL, 0); } @finally { [self freeMemory: values]; } @@ -194,12 +194,12 @@ [command appendFormat: @"$%zd", ++i]; } [command appendString: @")"]; - result = PQexecParams(conn, [command UTF8String], (int)count, - NULL, values, NULL, NULL, 0); + result = PQexecParams(_connnection, [command UTF8String], + (int)count, NULL, values, NULL, NULL, 0); } @finally { [self freeMemory: values]; } [pool release]; @@ -229,8 +229,8 @@ [pool release]; } - (PGconn*)PG_connection { - return conn; + return _connnection; } @end