2007-10-03 00:03:27 +02:00
|
|
|
/*
|
|
|
|
Copyright (C) 2004-2005 SKYRIX Software AG
|
|
|
|
|
|
|
|
This file is part of OpenGroupware.org.
|
|
|
|
|
|
|
|
OGo is free software; you can redistribute it and/or modify it under
|
|
|
|
the terms of the GNU Lesser General Public License as published by the
|
|
|
|
Free Software Foundation; either version 2, or (at your option) any
|
|
|
|
later version.
|
|
|
|
|
|
|
|
OGo is distributed in the hope that it will be useful, but WITHOUT ANY
|
|
|
|
WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
|
|
|
FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
|
|
|
|
License for more details.
|
|
|
|
|
|
|
|
You should have received a copy of the GNU Lesser General Public
|
|
|
|
License along with OGo; see the file COPYING. If not, write to the
|
|
|
|
Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA
|
|
|
|
02111-1307, USA.
|
|
|
|
*/
|
|
|
|
|
2008-12-12 18:57:23 +01:00
|
|
|
#import <Foundation/NSArray.h>
|
|
|
|
#import <Foundation/NSString.h>
|
|
|
|
|
|
|
|
#import "EOAdaptorChannel+GCS.h"
|
2007-10-03 00:03:27 +02:00
|
|
|
|
|
|
|
@implementation EOAdaptorChannel(GCS)
|
|
|
|
|
2008-06-30 16:08:10 +02:00
|
|
|
- (BOOL) tableExistsWithName: (NSString *) _tableName
|
|
|
|
{
|
2007-10-03 00:03:27 +02:00
|
|
|
NSException *ex;
|
|
|
|
NSString *sql;
|
|
|
|
BOOL didOpen;
|
|
|
|
|
|
|
|
didOpen = NO;
|
|
|
|
if (![self isOpen]) {
|
|
|
|
if (![self openChannel])
|
|
|
|
return NO;
|
|
|
|
didOpen = YES;
|
|
|
|
}
|
|
|
|
|
|
|
|
sql = @"SELECT COUNT(*) FROM ";
|
|
|
|
sql = [sql stringByAppendingString:_tableName];
|
|
|
|
sql = [sql stringByAppendingString:@" WHERE 1 = 2"];
|
|
|
|
|
|
|
|
ex = [[[self evaluateExpressionX:sql] retain] autorelease];
|
|
|
|
[self cancelFetch];
|
|
|
|
|
|
|
|
if (didOpen) [self closeChannel];
|
|
|
|
return ex != nil ? NO : YES;
|
|
|
|
}
|
|
|
|
|
2008-06-30 16:08:10 +02:00
|
|
|
- (void) dropTables: (NSArray *) tableNames
|
|
|
|
{
|
|
|
|
unsigned int count, max;
|
|
|
|
NSString *sql;
|
|
|
|
|
|
|
|
max = [tableNames count];
|
|
|
|
for (count = 0; count < max; count++)
|
|
|
|
{
|
|
|
|
sql = [NSString stringWithFormat: @"DROP TABLE %@",
|
|
|
|
[tableNames objectAtIndex: count]];
|
|
|
|
[self evaluateExpressionX: sql];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2007-10-03 00:03:27 +02:00
|
|
|
@end /* EOAdaptorChannel(GCS) */
|