aboutsummaryrefslogtreecommitdiffstats
path: root/Frameworks/SPMySQLFramework/Source/SPMySQLConnection Categories
diff options
context:
space:
mode:
Diffstat (limited to 'Frameworks/SPMySQLFramework/Source/SPMySQLConnection Categories')
-rw-r--r--Frameworks/SPMySQLFramework/Source/SPMySQLConnection Categories/Querying & Preparation.h6
-rw-r--r--Frameworks/SPMySQLFramework/Source/SPMySQLConnection Categories/Querying & Preparation.m21
2 files changed, 26 insertions, 1 deletions
diff --git a/Frameworks/SPMySQLFramework/Source/SPMySQLConnection Categories/Querying & Preparation.h b/Frameworks/SPMySQLFramework/Source/SPMySQLConnection Categories/Querying & Preparation.h
index ff55f796..9ab8bc6a 100644
--- a/Frameworks/SPMySQLFramework/Source/SPMySQLConnection Categories/Querying & Preparation.h
+++ b/Frameworks/SPMySQLFramework/Source/SPMySQLConnection Categories/Querying & Preparation.h
@@ -45,6 +45,10 @@
- (id)streamingQueryString:(NSString *)theQueryString useLowMemoryBlockingStreaming:(BOOL)fullStreaming;
- (id)queryString:(NSString *)theQueryString usingEncoding:(NSStringEncoding)theEncoding withResultType:(SPMySQLResultType)theReturnType;
+// Query convenience functions
+- (NSArray *)getAllRowsFromQuery:(NSString *)theQueryString;
+- (id)getFirstFieldFromQuery:(NSString *)theQueryString;
+
// Query information
- (unsigned long long)rowsAffectedByLastQuery;
- (unsigned long long)lastInsertID;
@@ -100,4 +104,4 @@ static inline id SPMySQLConnectionQueryString(SPMySQLConnection* self, NSString
if (!cachedMethodPointer) cachedMethodPointer = (SPMySQLConnectionQueryStringMethodPtr)[self methodForSelector:cachedSelector];
return cachedMethodPointer(self, cachedSelector, theQueryString, theEncoding, theReturnType);
-} \ No newline at end of file
+}
diff --git a/Frameworks/SPMySQLFramework/Source/SPMySQLConnection Categories/Querying & Preparation.m b/Frameworks/SPMySQLFramework/Source/SPMySQLConnection Categories/Querying & Preparation.m
index 4134880c..e3ce599a 100644
--- a/Frameworks/SPMySQLFramework/Source/SPMySQLConnection Categories/Querying & Preparation.m
+++ b/Frameworks/SPMySQLFramework/Source/SPMySQLConnection Categories/Querying & Preparation.m
@@ -357,6 +357,27 @@
}
#pragma mark -
+#pragma mark Query convenience functions
+
+/**
+ * Run a query and retrieve the entire result set as an array of dictionaries.
+ * Returns nil if there was a problem running the query or retrieving any results.
+ */
+- (NSArray *)getAllRowsFromQuery:(NSString *)theQueryString
+{
+ return [[self queryString:theQueryString] getAllRows];
+}
+
+/**
+ * Run a query and retrieve the first field of any response. Returns nil if there
+ * was a problem running the query or retrieving any results.
+ */
+- (id)getFirstFieldFromQuery:(NSString *)theQueryString
+{
+ return [[[self queryString:theQueryString] getRowAsArray] objectAtIndex:0];
+}
+
+#pragma mark -
#pragma mark Query information
/**