aboutsummaryrefslogtreecommitdiffstats
path: root/Source/TableDocument.m
diff options
context:
space:
mode:
authorBibiko <bibiko@eva.mpg.de>2009-06-05 17:44:48 +0000
committerBibiko <bibiko@eva.mpg.de>2009-06-05 17:44:48 +0000
commit7b5f4d96727a505b67b7970e0b4f2ca1de0394a2 (patch)
tree79c322f805286c5cfa1e37c40da9e8e8278b458a /Source/TableDocument.m
parent67a3148cec8bc7d1c6f52f60c8ce93a4fe0b8ece (diff)
downloadsequelpro-7b5f4d96727a505b67b7970e0b4f2ca1de0394a2.tar.gz
sequelpro-7b5f4d96727a505b67b7970e0b4f2ca1de0394a2.tar.bz2
sequelpro-7b5f4d96727a505b67b7970e0b4f2ca1de0394a2.zip
• reload table list, database pull-down menu according to user's statements in the Custom Query editor if necessary
- if statement begins with: use, create, alter, rename, drop • reload table list, database pull-down menu according to imported statements • sped up "Import MySQL Dump" • fixed some tiny issues of the last commit
Diffstat (limited to 'Source/TableDocument.m')
-rw-r--r--Source/TableDocument.m41
1 files changed, 41 insertions, 0 deletions
diff --git a/Source/TableDocument.m b/Source/TableDocument.m
index 192c93a5..cea86c3c 100644
--- a/Source/TableDocument.m
+++ b/Source/TableDocument.m
@@ -911,6 +911,47 @@ NSString *TableDocumentFavoritesControllerSelectionIndexDidChange = @"TableDocum
[alert beginSheetModalForWindow:tableWindow modalDelegate:self didEndSelector:@selector(sheetDidEnd:returnCode:contextInfo:) contextInfo:@"removedatabase"];
}
+/*
+ * Reset the current selected database name
+ */
+- (void) refreshCurrentDatabase
+{
+ NSString *dbName;
+
+ // Notify listeners that a query has started
+ [[NSNotificationCenter defaultCenter] postNotificationName:@"SMySQLQueryWillBePerformed" object:self];
+
+ CMMCPResult *theResult = [mySQLConnection queryString:@"SELECT DATABASE()"];
+ if ( [[mySQLConnection getLastErrorMessage] isEqualToString:@""] ) {
+ int i;
+ int r = [theResult numOfRows];
+ if (r) [theResult dataSeek:0];
+ for ( i = 0 ; i < r ; i++ ) {
+ dbName = [[theResult fetchRowAsArray] objectAtIndex:0];
+ }
+ if(![dbName isKindOfClass:[NSNull class]]) {
+ if(![dbName isEqualToString:selectedDatabase]) {
+ if (selectedDatabase) {
+ [selectedDatabase release];
+ selectedDatabase = nil;
+ }
+ selectedDatabase = [dbName retain];
+ [chooseDatabaseButton selectItemWithTitle:selectedDatabase];
+ [tableWindow setTitle:[NSString stringWithFormat:@"(MySQL %@) %@/%@", mySQLVersion, [self name], selectedDatabase]];
+ }
+ } else {
+ [selectedDatabase release];
+ selectedDatabase = nil;
+ [chooseDatabaseButton selectItemAtIndex:0];
+ [tableWindow setTitle:[NSString stringWithFormat:@"(MySQL %@) %@/", mySQLVersion, [self name]]];
+ }
+ }
+
+ //query finished
+ [[NSNotificationCenter defaultCenter] postNotificationName:@"SMySQLQueryHasBeenPerformed" object:self];
+
+}
+
#pragma mark -
#pragma mark Console methods