???????
????SQLite (http://www.sqlite.org/docs.html) ????????????????????iOS SDK?????????SQLite?????????????????? libsqlite3.dylib ??????????? sqlite3.h ???????ɡ???????????SQLite API???????????????????????????????????????????г????????н?SQLite API???з???????FMDB (https://github.com/tryingx/fmdb-master) ???????????е????
????????? ????sqlite3?????
????????? ????FMDB?????
????????????????????
?????????????????????????????ú??
????????? ??????????????

 

1 NSString *docPath = [NSSearchPathForDirectoriesInDomains(NSDocumentDirectory?? NSUserDomainMask?? YES) objectAtIndex:0]; // ???document?????·??
2 /**
3  *  ??????????????????????????????"" ???? NULL
4  *
5  *  An empty string (@""). An empty database is created at a temporary location. This database is deleted with the FMDatabase connection is closed.
6  ??????????????(@"")??????????????????????????????????????
7  NULL. An in-memory database is created. This database will be destroyed with the FMDatabase connection is closed.
8  ??????и?????????????
9  */
10 NSString *dbPath = [docPath stringByAppendingPathComponent:@"student.sqlite"];
11 NSLog(@"%@"?? dbPath); // ????????
12 FMDatabase *dataBase = [FMDatabase databaseWithPath:dbPath];
13 [dataBase open];
14 // ?????ж????????????
15 if (![dataBase open]) {
16     NSLog(@"error");
17 }

 

????????? ??????Щ????????
???????ò?????
????1.?????????
????NSString *sql = @"CREATE TABLE student(_id Integer primary key?? name text?? password text?? email text)";
????BOOL isCreateTable = [dataBase executeStatements:sql];
????NSLog(@"%d"?? isCreateTable );
????2.????????
????NSString *sqlInsert = @"INSERT INTO student (name?? password?? email) values ('????'?? '1232'?? '3343243')";
????BOOL isInsertOK = [dataBase executeStatements:sqlInsert];
????NSLog(@"%d"?? isInsertOK );