FMDB 操作数据库
来源:互联网 发布:淘宝充值平台押金 编辑:程序博客网 时间:2024/05/29 17:24
操作数据库,之前,统一操作:
if (![db open]) {
[db release];
return;
}
之后统一操作:
[db close];
1、创建表:
[db executeUpdate:[NSString stringWithFormat:@"CREATE TABLE %@ (title text,id text UNIQUE,image text,user text,article text,time text,rt text,text text,weight text,desc text,type text,comments text,reposts text)",tablename]];
2、插入数据:
BOOL isSuccess = [db executeUpdate:[NSString stringWithFormat:@"insert into %@ (title,id,image,user,article,time,rt,text,weight,desc,type,comments,reposts) values(?,?,?,?,?,?,?,?,?,?,?,?,?)",tablename],
status.title,
status.id_ ,
imagedict,
userdict,
articledict,
status.time,
rtdict,
status.text,
status.weight,
status.desc,
status.type,
status.comments,
status.reposts
];
3、查找数据:
FMResultSet *rs = [db executeQuery:[NSString stringWithFormat:@"select * from %@ where id = ?",tablename],[statusIdArray objectAtIndex:i]];
while ([rs next]) {
NSMutableDictionary* statusdict = [[NSMutableDictionary alloc] init];
if ([rs stringForColumn:@"title"])
[statusdict setObject:[rs stringForColumn:@"title"] forKey:@"title"];
。。。。。。
}
4、删除指定表的数据:
NSString *delegeTable = [NSString stringWithFormat:@"delete from %@",[NSString stringWithFormat:@"section_statuses_%@", sectionId]];
[db executeUpdate:delegeTable];
5、删除所有表的数据:
[db executeUpdate:[NSString stringWithFormat:@"delete * from %@",tablename]];
6、查询当前表中的数据条数
[db intForQuery:[NSString stringWithFormat:@"select count(id) from %@",tablename]];
if (![db open]) {
[db release];
return;
}
之后统一操作:
[db close];
1、创建表:
[db executeUpdate:[NSString stringWithFormat:@"CREATE TABLE %@ (title text,id text UNIQUE,image text,user text,article text,time text,rt text,text text,weight text,desc text,type text,comments text,reposts text)",tablename]];
2、插入数据:
BOOL isSuccess = [db executeUpdate:[NSString stringWithFormat:@"insert into %@ (title,id,image,user,article,time,rt,text,weight,desc,type,comments,reposts) values(?,?,?,?,?,?,?,?,?,?,?,?,?)",tablename],
status.title,
status.id_ ,
imagedict,
userdict,
articledict,
status.time,
rtdict,
status.text,
status.weight,
status.desc,
status.type,
status.comments,
status.reposts
];
3、查找数据:
FMResultSet *rs = [db executeQuery:[NSString stringWithFormat:@"select * from %@ where id = ?",tablename],[statusIdArray objectAtIndex:i]];
while ([rs next]) {
NSMutableDictionary* statusdict = [[NSMutableDictionary alloc] init];
if ([rs stringForColumn:@"title"])
[statusdict setObject:[rs stringForColumn:@"title"] forKey:@"title"];
。。。。。。
}
4、删除指定表的数据:
NSString *delegeTable = [NSString stringWithFormat:@"delete from %@",[NSString stringWithFormat:@"section_statuses_%@", sectionId]];
[db executeUpdate:delegeTable];
5、删除所有表的数据:
[db executeUpdate:[NSString stringWithFormat:@"delete * from %@",tablename]];
6、查询当前表中的数据条数
[db intForQuery:[NSString stringWithFormat:@"select count(id) from %@",tablename]];
0 0
- 数据库操作(使用FMDB)
- 数据库操作(使用FMDB)
- 数据库操作(使用FMDB)
- FMDB 数据库简单操作
- 数据库操作(使用FMDB)
- 数据库操作 FMDB
- 数据库操作(使用FMDB)
- 数据库操作(使用FMDB)
- 数据库操作FMDB
- FMDB操作数据库
- 数据库操作(使用FMDB)
- 数据库操作(使用FMDB)
- 数据库操作(使用FMDB)
- 数据库操作(使用FMDB)
- 217,FMDB数据库操作
- 使用FMDB操作数据库
- 数据库操作(使用FMDB)
- FMDB 操作数据库
- VIM 高效操作
- UVA_10422_Knights in FEN
- 在CentOS 7上构建RAID5、LVM和SAMBA服务器(4)——逻辑卷(组)扩容
- lintcode:Word Ladder II
- 《JAVA并发编程实践》学习笔记(第六.七章)
- FMDB 操作数据库
- 需求分析
- handle机制
- 循序渐进之Spring AOP(2) - 基本概念
- Mybatis入门配置及基本查询
- FMDB简介
- 全国首堂沉浸式教学系统实验课开启了虚拟现实教育的新纪元
- 图像分割——区域生长法
- 第一篇博客