aboutsummaryrefslogtreecommitdiffstats
path: root/Frameworks/PostgresKit/Source/PGPostgresConnectionQueryExecution.m
diff options
context:
space:
mode:
authorstuconnolly <stuart02@gmail.com>2013-06-18 13:38:26 +0000
committerstuconnolly <stuart02@gmail.com>2013-06-18 13:38:26 +0000
commit80c152501303c0ed7bd530f5e05bc7e5a6fba7f5 (patch)
tree4b1e7106a4b32a21a9aa9e050c9851908949484b /Frameworks/PostgresKit/Source/PGPostgresConnectionQueryExecution.m
parent33dbe8d35c3e681c5a8cfd223be50ae7c769cf15 (diff)
downloadsequelpro-80c152501303c0ed7bd530f5e05bc7e5a6fba7f5.tar.gz
sequelpro-80c152501303c0ed7bd530f5e05bc7e5a6fba7f5.tar.bz2
sequelpro-80c152501303c0ed7bd530f5e05bc7e5a6fba7f5.zip
PostgresKit: Add a new property to return the number of rows affected by the last executed query.
Diffstat (limited to 'Frameworks/PostgresKit/Source/PGPostgresConnectionQueryExecution.m')
-rw-r--r--Frameworks/PostgresKit/Source/PGPostgresConnectionQueryExecution.m40
1 files changed, 22 insertions, 18 deletions
diff --git a/Frameworks/PostgresKit/Source/PGPostgresConnectionQueryExecution.m b/Frameworks/PostgresKit/Source/PGPostgresConnectionQueryExecution.m
index 3de02350..7e0aa18a 100644
--- a/Frameworks/PostgresKit/Source/PGPostgresConnectionQueryExecution.m
+++ b/Frameworks/PostgresKit/Source/PGPostgresConnectionQueryExecution.m
@@ -199,18 +199,18 @@ PGQueryParamData;
}
// Execute the command - return data in binary
- PGresult *result = nil;
+ PGresult *pgResult = nil;
if ([query isKindOfClass:[NSString class]]) {
- result = PQexecParams(_connection,
- [(NSString *)query UTF8String],
- paramData->paramNum,
- paramData->paramTypes,
- (const char **)paramData->paramValues,
- (const int *)paramData->paramLengths,
- (const int *)paramData->paramFormats,
- PGPostgresResultsAsBinary);
+ pgResult = PQexecParams(_connection,
+ [(NSString *)query UTF8String],
+ paramData->paramNum,
+ paramData->paramTypes,
+ (const char **)paramData->paramValues,
+ (const int *)paramData->paramLengths,
+ (const int *)paramData->paramFormats,
+ PGPostgresResultsAsBinary);
}
else if ([query isKindOfClass:[PGPostgresStatement class]]) {
PGPostgresStatement *statement = (PGPostgresStatement *)query;
@@ -222,20 +222,24 @@ PGQueryParamData;
if (!prepareResult || ![statement name]) return nil;
}
- result = PQexecPrepared(_connection,
- [statement UTF8Name],
- paramData->paramNum,
- (const char **)paramData->paramValues,
- (const int *)paramData->paramLengths,
- (const int *)paramData->paramFormats,
- PGPostgresResultsAsBinary);
+ pgResult = PQexecPrepared(_connection,
+ [statement UTF8Name],
+ paramData->paramNum,
+ (const char **)paramData->paramValues,
+ (const int *)paramData->paramLengths,
+ (const int *)paramData->paramFormats,
+ PGPostgresResultsAsBinary);
}
[self _destroyParamDataStructure:paramData];
- if (!result || [self _queryDidError:result]) return nil;
+ if (!pgResult || [self _queryDidError:pgResult]) return nil;
+
+ PGPostgresResult *result = [[[PGPostgresResult alloc] initWithResult:pgResult connection:self] autorelease];
- return [[[PGPostgresResult alloc] initWithResult:result connection:self] autorelease];
+ _lastQueryAffectedRowCount = [result numberOfRows];
+
+ return result;
}
/**