aboutsummaryrefslogtreecommitdiffstats
path: root/Source/SPDatabaseData.m
diff options
context:
space:
mode:
authorrowanbeentje <rowan@beent.je>2012-02-23 02:13:56 +0000
committerrowanbeentje <rowan@beent.je>2012-02-23 02:13:56 +0000
commit05f1612cbb7e33cf9135a346fc2505cc0e87e853 (patch)
tree785824be4e44a61389271343d958851fa4ff7dd0 /Source/SPDatabaseData.m
parenta889340b9cb1eca0d3ff022e8e6e2c718480bf44 (diff)
downloadsequelpro-05f1612cbb7e33cf9135a346fc2505cc0e87e853.tar.gz
sequelpro-05f1612cbb7e33cf9135a346fc2505cc0e87e853.tar.bz2
sequelpro-05f1612cbb7e33cf9135a346fc2505cc0e87e853.zip
Warning: this branch commit is largely untested, and known to throw exceptions as database structure retrieval is currently missing!
Further work on SPMySQLFramework integration: - Improve SPMySQL framework build settings including correct ppc builds and a Distribution configuration for the build distributions to match - Add new convenience querying and result methods to the framework - Amend Sequel Pro source to use the new SPMySQL.framework methods everywhere, replacing MCPKit methods where they differ and improving some functions - Remove MCPKit from the source - Fix a number of warnings on Release-style builds
Diffstat (limited to 'Source/SPDatabaseData.m')
-rw-r--r--Source/SPDatabaseData.m32
1 files changed, 12 insertions, 20 deletions
diff --git a/Source/SPDatabaseData.m b/Source/SPDatabaseData.m
index 2aa809b1..2e827fa9 100644
--- a/Source/SPDatabaseData.m
+++ b/Source/SPDatabaseData.m
@@ -26,10 +26,11 @@
#import "SPDatabaseData.h"
#import "SPServerSupport.h"
#import "SPDatabaseCharacterSets.h"
+#import "SPMySQL.h"
@interface SPDatabaseData (PrivateAPI)
-- (NSMutableArray *)_getDatabaseDataForQuery:(NSString *)query;
+- (NSArray *)_getDatabaseDataForQuery:(NSString *)query;
NSInteger _sortMySQL4CharsetEntry(NSDictionary *itemOne, NSDictionary *itemTwo, void *context);
@@ -162,12 +163,12 @@ NSInteger _sortMySQL4CharsetEntry(NSDictionary *itemOne, NSDictionary *itemTwo,
[storageEngines addObject:[NSDictionary dictionaryWithObject:@"MyISAM" forKey:@"Engine"]];
// Check if InnoDB support is enabled
- MCPResult *result = [connection queryString:@"SHOW VARIABLES LIKE 'have_innodb'"];
+ SPMySQLResult *result = [connection queryString:@"SHOW VARIABLES LIKE 'have_innodb'"];
[result setReturnDataAsStrings:YES];
- if ([result numOfRows] == 1) {
- if ([[[result fetchRowAsDictionary] objectForKey:@"Value"] isEqualToString:@"YES"]) {
+ if ([result numberOfRows] == 1) {
+ if ([[[result getRowAsDictionary] objectForKey:@"Value"] isEqualToString:@"YES"]) {
[storageEngines addObject:[NSDictionary dictionaryWithObject:@"InnoDB" forKey:@"Engine"]];
}
}
@@ -201,9 +202,9 @@ NSInteger _sortMySQL4CharsetEntry(NSDictionary *itemOne, NSDictionary *itemTwo,
if ([serverSupport supportsInformationSchemaEngines])
{
// Check the information_schema.engines table is accessible
- MCPResult *result = [connection queryString:@"SHOW TABLES IN information_schema LIKE 'ENGINES'"];
+ SPMySQLResult *result = [connection queryString:@"SHOW TABLES IN information_schema LIKE 'ENGINES'"];
- if ([result numOfRows] == 1) {
+ if ([result numberOfRows] == 1) {
// Table is accessible so get available storage engines
// Note, that the case of the column names specified in this query are important.
@@ -212,7 +213,7 @@ NSInteger _sortMySQL4CharsetEntry(NSDictionary *itemOne, NSDictionary *itemTwo,
}
else {
// Get storage engines
- NSMutableArray *engines = [self _getDatabaseDataForQuery:@"SHOW STORAGE ENGINES"];
+ NSArray *engines = [self _getDatabaseDataForQuery:@"SHOW STORAGE ENGINES"];
// We only want to include engines that are supported
for (NSDictionary *engine in engines)
@@ -308,22 +309,13 @@ NSInteger _sortMySQL4CharsetEntry(NSDictionary *itemOne, NSDictionary *itemTwo,
* Executes the supplied query against the current connection and returns the result as an array of
* NSDictionarys, one for each row.
*/
-- (NSMutableArray *)_getDatabaseDataForQuery:(NSString *)query
+- (NSArray *)_getDatabaseDataForQuery:(NSString *)query
{
- NSMutableArray *array = [NSMutableArray array];
+ SPMySQLResult *result = [connection queryString:query];
- MCPResult *result = [connection queryString:query];
+ if ([connection queryErrored]) return [NSArray array];
- if (![connection queryErrored]) {
- [result dataSeek:0];
-
- for (NSUInteger i = 0; i < [result numOfRows]; i++)
- {
- [array addObject:[result fetchRowAsDictionary]];
- }
- }
-
- return array;
+ return [result getAllRows];
}
/**