101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
|
values = [self allocMemoryWithSize: sizeof(*values)
count: argsCount];
@try {
size_t i = 0;
do {
if ([parameter isKindOfClass: [OFNull class]])
values[i++] = NULL;
else if ([parameter isKindOfClass: [OFNumber class]]) {
switch ([parameter type]) {
case OF_NUMBER_BOOL:
if ([parameter boolValue])
values[i++] = "t";
else
values[i++] = "f";
break;
default:
values[i++] = [[parameter description]
UTF8String];
break;
}
} 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];
}
|
|
|
>
>
|
>
|
|
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
|
values = [self allocMemoryWithSize: sizeof(*values)
count: argsCount];
@try {
size_t i = 0;
do {
if ([parameter isKindOfClass: [OFString class]])
values[i++] = [parameter UTF8String];
else if ([parameter isKindOfClass: [OFNumber class]]) {
switch ([parameter type]) {
case OF_NUMBER_BOOL:
if ([parameter boolValue])
values[i++] = "t";
else
values[i++] = "f";
break;
default:
values[i++] = [[parameter description]
UTF8String];
break;
}
} else if ([parameter isKindOfClass: [OFNull class]])
values[i++] = NULL;
else
values[i++] = [[parameter description]
UTF8String];
} while ((parameter = va_arg(args, id)) != nil);
result = PQexecParams(conn, [command UTF8String],
argsCount, NULL, values, NULL, NULL, 0);
} @finally {
[self freeMemory: values];
}
|