FMDB
来源:互联网 发布:淘宝天天特价报名条件 编辑:程序博客网 时间:2024/05/16 17:49
[self.dbQueueinDatabase:^(FMDatabase *db) {
[dbopen];
BOOL stored = NO;
//如果表不存在,建表
NSString *sqlstr = [NSStringstringWithFormat:@"create table if not exists favoriteList (title,description,indexID,created,thumbnail,source,thumbnail_top)"];
[dbexecuteUpdate:sqlstr];
//查询存在与否
NSString * string = [NSStringstringWithFormat:@"select * from favoriteList where indexID = ?"];
FMResultSet * rs = [db executeQuery:string,news._id];
//如果存在。。。。
while ([rs next]) {
stored =YES;
break;
}
if (!stored) {
NSString * sql = [NSStringstringWithFormat:@"insert into favoriteList (title,description,indexID,created,thumbnail,source,thumbnail_top) values (?,?,?,?,?,?,?)"];
int i = [db executeUpdate:sql,news.title,news.descriptions,news._id,news.created,news.thumbnail,news.source,news.thumbnail_top];
if (i) {
UIAlertView * alertView = [[UIAlertViewalloc]initWithTitle:nilmessage:@"收藏成功"delegate:nilcancelButtonTitle:@"确定"otherButtonTitles:nil,nil];
[alertViewshow];
}
}
[dbclose];
}];
- FMDB
- FMDB
- FMDB
- FMDB
- FMDB
- fmdb
- FMDB
- FMDB
- fmdb
- FMDB
- FMDB
- fmdb
- FMDB
- FMDB
- FMDB
- FMDB
- FMDB
- FMDB
- Android每日范例——TextView文字内容更改
- LeetCodeOJ.Longest Substring Without Repeating Characters
- windows下python实现截图功能
- Android GUI之Window、WindowManager
- C++ 析构函数
- FMDB
- IBeacon技术
- dom4j方式写入xml
- arm-linux-gcc(ubuntu)安装
- JSON和JSONP
- Java集合数组列表中的数据排序
- (1) SQL简介
- 二维数组中的查找(剑指offer)
- 代理设计模式