SQL 语句记录

1.创建一个table @"create table rockTB(myId integer primary key autoincrement not null, time varchar(128) , body varchar(1024))"];

2.查询 

 FMResultSet * result = [sDB executeQuery:@"select * from rockTB"];

    while ([result next])

    {

        NSString * time = [result stringForColumn:@"time"];

        NSString * body = [result stringForColumn:@"body"];

        int myId = [result intForColumn:@"myId"];

        

        NSLog(@"time:%@ body:%@ myId:%d",time,body,myId);

    }

 

3.更新 

  NSString * str = [NSString stringWithFormat:@"update rockTB SET title = '%@' ,body = '%@' WHERE myId = %d",

                      info.title, info.body, info.aId];

    BOOL ret = [sDB executeUpdate:str];

posted on 2015-05-31 19:26  景树园  阅读(130)  评论(0编辑  收藏  举报

导航