Fmdb is a lightweight database in a Xcode that is used to store network resources locally. Therefore, Fmdb is a very practical, very important point of knowledge. Here is a simple example, based on the fmdb of the TIM-censored operations, the code may be more messy, I hope not to hurt your eyes. It is very simple to add delete changes, do not need to do too many operations, only need to use the Fmdb encapsulation of the good executeupdate method on the line.
First step, add the Sqlite3 package file
As shown in the figure, select and find the engineering name->build Phases->link binary with libraries press the plus key below, search the pop-up search box for sqlite3, select libsqlite3.dylib-> Add At this point, you have finished adding. Then import Fmdb this package in pod.
The second step, increase, delete, change, check the realization
#pragma mark - fmdb database Operations//inserts-(void) Insert { if ([_db open]) { nsstring *sql1 = [nsstring stringwithformat: @ "insert into '%@ ' ('%@ ', '%@ ', ', '%@ ', '%@ ' ', ',"%@ ', '%@ '),
nbsp
'%@ ', '%@ ', '%@ ', '%@ ') VALUES ('%@ ', '%@ ', ',%@ ', '%@ ', ', '%@ ' , '%@ ', '%@ ', '%@ ', '%@ ', ' "%@ ')", &nbs p; tablename, @ " Starting ", @" destination ", @" Goodsname ", @" car ", @" Goodsweight ", @" Goodsvolume ", @" Intentionprice ", @" bail ", @" Mark ", @" status ", _startinglabel.text,_destinationlabel.text,gOodsnametextfield.text,selectvehiclelabel.text,goodsweighttextfield.text,goodsvolumetextfield.text,
intentionpricetextfield.text,bailtextfield.text,marklabel.text,@ "0"];
BOOL res = [_db executeUpdate:sql1]; if (!res) {
nslog (@ "error when insert db table"); } else { nslog (@ "
Success to insert db table ");
} [_db close];    &NBSP}}//Modify-(void) Update { if ([_db open]) { &nbs p; nsstring *updatesql = [nsstring stringwithformat:@ "update %@ set %@= '%@ ' where %@= '%@ ', tablename,destination, @ "destination Shanghai", Starting,@ "Wuhu Departure"];
BOOL res = [_db executeUpdate:updateSql]; if (!res) {
nslog (@ "error when insert db table"); } else {
nslog (@ "success to insert db table"); } [_db
Close];    &NBSP} }//delete-(void) Delete { if ([_db open])   ; { NSString *deleteSql = [NSString stringWithFormat: @ " delete from %@ where %@ = '%@ ',
tablename, starting, @ "Wuhu Departure"]; bool res = [_db executeupdate:
Deletesql]; if (!res) { nslog (@ "error when insert db table")
; } else {
nslog (@ "success to insert db table"); } [_db close];     &NBSP}} //query - (void) query {    &NBSP ; if ([_db open]) { nsstring * sql = [nsstring stringwithformat: @ "
select * from %@ ", TableName]; FMResultSet * rs = [_db
Executequery:sql]; while ([Rs next]) { int id = [rs intforcolumn:@ "Id
"]; nsstring * name = [rs stringforcolumn:starting]; nsstring * age =
[rs stringForColumn:DESTINATION]; nsstring * address
= [rs stringForColumn:GOODSNAME]; nslog (@ "id = %d, name = %@, age = %@ address = %@ ", Id, name, age,
address); } [
_db close];     &NBSP}}
To this end, the change and deletion of the search has been completed, may not see very understand me some of the variables, in fact, the variables are secondary, real operation add and remove changes to check on those few keywords, like inserted in the @ "insert into the '%@ ' ('%@ ', '%@ ', ...) VALUES ( '%@ ', '%@ ',...) ', the first%@ represents the name of the table, the names of the elements in the table in parentheses, and multiple%@ in the following values are the values of one by one corresponding to the preceding elements. OK, so here's the introduction, thanks for viewing.