forked from tidev/titanium-sdk
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDatabaseModule.m
50 lines (40 loc) · 1.18 KB
/
DatabaseModule.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
/**
* Appcelerator Titanium Mobile
* Copyright (c) 2009-2010 by Appcelerator, Inc. All Rights Reserved.
* Licensed under the terms of the Apache Public License
* Please see the LICENSE included with this distribution for details.
*/
#ifdef USE_TI_DATABASE
#import "DatabaseModule.h"
#import "TiDatabaseProxy.h"
@implementation DatabaseModule
-(void)startup
{
// enable multi-threading
sqlite3_enable_shared_cache(TRUE);
}
-(id)open:(id)path
{
ENSURE_SINGLE_ARG(path,NSString);
TiDatabaseProxy *db = [[[TiDatabaseProxy alloc] _initWithPageContext:[self executionContext] args:nil] autorelease];
[db open:path];
return db;
}
-(id)install:(id)args
{
ENSURE_ARG_COUNT(args,2);
TiDatabaseProxy *db = [[[TiDatabaseProxy alloc] _initWithPageContext:[self executionContext] args:nil] autorelease];
[db install:[args objectAtIndex:0] name:[args objectAtIndex:1]];
return db;
}
#define DB_CONSTANT(name, num) \
-(id)name {\
return NUMINT(num);\
}
DB_CONSTANT(FIELD_TYPE_UNKNOWN, FieldTypeUnknown)
DB_CONSTANT(FIELD_TYPE_STRING, FieldTypeString)
DB_CONSTANT(FIELD_TYPE_INT, FieldTypeInt)
DB_CONSTANT(FIELD_TYPE_FLOAT, FieldTypeFloat)
DB_CONSTANT(FIELD_TYPE_DOUBLE, FieldTypeDouble);
@end
#endif