diff options
author | stuconnolly <stuart02@gmail.com> | 2012-03-25 19:36:35 +0000 |
---|---|---|
committer | stuconnolly <stuart02@gmail.com> | 2012-03-25 19:36:35 +0000 |
commit | e516badf6b875c27ce095c9987aaa4004b98844e (patch) | |
tree | d0dd66e86e998b062cc36aab8644a47c7e9e03cd /Frameworks/QueryKit | |
parent | c79d9608d59d6daf5a644a48881b621316206c4e (diff) | |
download | sequelpro-e516badf6b875c27ce095c9987aaa4004b98844e.tar.gz sequelpro-e516badf6b875c27ce095c9987aaa4004b98844e.tar.bz2 sequelpro-e516badf6b875c27ce095c9987aaa4004b98844e.zip |
QueryKit: add clear method so query instances can be reused.
Diffstat (limited to 'Frameworks/QueryKit')
-rw-r--r-- | Frameworks/QueryKit/Source/QKQuery.h | 1 | ||||
-rw-r--r-- | Frameworks/QueryKit/Source/QKQuery.m | 21 |
2 files changed, 22 insertions, 0 deletions
diff --git a/Frameworks/QueryKit/Source/QKQuery.h b/Frameworks/QueryKit/Source/QKQuery.h index 2132a158..c0f925bb 100644 --- a/Frameworks/QueryKit/Source/QKQuery.h +++ b/Frameworks/QueryKit/Source/QKQuery.h @@ -100,6 +100,7 @@ - (id)initWithTable:(NSString *)table; - (NSString *)query; +- (void)clear; - (void)addField:(NSString *)field; - (void)addFields:(NSArray *)fields; diff --git a/Frameworks/QueryKit/Source/QKQuery.m b/Frameworks/QueryKit/Source/QKQuery.m index d26b9f72..4be29ae2 100644 --- a/Frameworks/QueryKit/Source/QKQuery.m +++ b/Frameworks/QueryKit/Source/QKQuery.m @@ -100,11 +100,32 @@ static NSString *QKNoQueryTableException = @"QKNoQueryTable"; #pragma mark - #pragma mark Public API +/** + * Requests that the query be built. + * + * @return The generated query. + */ - (NSString *)query { return _query ? [self _buildQuery] : @""; } +/** + * Clears anything this instance should know about the query it's building. + */ +- (void)clear +{ + [self setTable:nil]; + [self setDatabase:nil]; + [self setQueryType:(QKQueryType)-1]; + + [_fields removeAllObjects]; + [_parameters removeAllObjects]; + [_updateParameters removeAllObjects]; + [_groupByFields removeAllObjects]; + [_orderByFields removeAllObjects]; +} + #pragma mark - #pragma mark Fields |