Differences From Artifact [8d29eddb59]:
- File PGConnection.m — part of check-in [de46b0e10c] at 2012-10-03 13:20:06 on branch trunk — Initial import. (user: js, size: 2831) [annotate] [blame] [check-ins using]
To Artifact [d345fef3f0]:
- File
PGConnection.m
— part of check-in
[d2fe40f160]
at
2012-10-05 20:17:45
on branch trunk
— Nicer API.
-[executeCommand:parameters:] is now a variadic function instead of
taking an array as argument. (user: js, size: 2883) [annotate] [blame] [check-ins using]
︙ | ︙ | |||
74 75 76 77 78 79 80 | return [PGResult PG_resultWithResult: result]; PQclear(result); return nil; } - (PGResult*)executeCommand: (OFString*)command | | > > > > > > > | < < < > | | | 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 | return [PGResult PG_resultWithResult: result]; PQclear(result); return nil; } - (PGResult*)executeCommand: (OFString*)command parameters: (id)parameter, ... { OFAutoreleasePool *pool = [[OFAutoreleasePool alloc] init]; PGresult *result; const char **values; va_list args, args2; size_t argsCount; va_start(args, parameter); va_copy(args2, args); for (argsCount = 1; va_arg(args2, id) != nil; argsCount++); values = [self allocMemoryWithSize: sizeof(*values) count: argsCount]; @try { size_t i = 0; do { if ([parameter isKindOfClass: [OFNull class]]) values[i++] = NULL; else values[i++] = [parameter UTF8String]; } while ((parameter = va_arg(args, id)) != nil); result = PQexecParams(conn, [command UTF8String], argsCount, NULL, values, NULL, NULL, 0); } @finally { [self freeMemory: values]; } [pool release]; if (PQresultStatus(result) == PGRES_FATAL_ERROR) { |
︙ | ︙ |