第三篇 FMDB的使用
来源:互联网 发布:淘宝直通车尺寸 编辑:程序博客网 时间:2024/06/05 05:57
使用第三方FMDB 应用内嵌sqlite
首先初始化数据库
#define DATABASENAME @"*******.sqlite3"
static NSString * dataBaseFilePath = nil;
static FMDatabase *db = nil;
{
if (!dataBaseFilePath)
{
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
NSString * documentDirectory = [paths objectAtIndex:0];
dataBaseFilePath = [documentDirectory stringByAppendingPathComponent:DATABASENAME];
}
return dataBaseFilePath;
}
然后建表
if(![db tableExists:@"orderTable"]){
[db executeUpdate:@"CREATE TABLE IF NOT EXISTS orderTable(_id INTEGER PRIMARY KEY AUTOINCREMENT,productGuid TEXT, goldCount TEXT ,theUsd TEXT , theState TEXT );"];
}
然后 操作
{
if (!db)
{
db = [self getDataBase];
}
[db open];
[self createTable];
[db beginTransaction]; //与commit 成对出现。查询时候不需要
//增
// [db executeUpdate:@"INSERT INTO orderTable(productGuid, goldCount,theUsd,theState) VALUES(?,?,?,?)",prductGuid,goldCount,usd,state];//删
// [db executeUpdate:@"DELETE from orderTable WHERE productGuid = ? ",pGuid];
//改
// [db executeUpdate:@"UPDATE orderTable SET goldCount = ? WHERE theUsd = ?",gold,usd];
//查
// FMResultSet *rs=[db executeQuery:@"select * from orderTable"];
// while ([rs next])
// {
//查处结果以后的操作
// }
// [rs close];
[db commit];
[db close];
}
- 第三篇 FMDB的使用
- FMDB的第三方库的使用
- iOS 第三方类库FMDB的使用
- FMDB第三方的使用笔记
- 第三方库 FMDB的使用
- sqlite第三方类库:FMDB使用
- sqlite第三方类库:FMDB使用
- Sqlite第三方类库:FMDB使用
- sqlite第三方类库:FMDB使用
- Sqlite第三方类库:FMDB使用
- sqlite第三方类库:FMDB使用
- sqlite第三方类库:FMDB使用
- sqlite第三方类库:FMDB使用
- 第三方框架FMDB使用
- 数据库第三方FMDB使用
- iOS关于数据库的操作(使用第三方类库FMDB)
- iOS关于数据库的操作(使用第三方类库FMDB)
- iOS开发之Sqlite 第三方库FMDB的使用
- 邮箱正则表达式
- IE9 下ajax动态记载table布局错乱问题。
- C#中用Invoke调用控件方法和BeginInvoke线程使用方法
- Codeforces 300C
- 【黑马程序员】Java基础加强17:类加载器ClassLoader
- 第三篇 FMDB的使用
- CGIC标准库在Android4.0平台的测试(cgictest的测试)跟踪报告
- POJ 2528 Mayor's posters(set+线段树)
- java中split(regex)使用中要注意的问题:正则表达式
- SQLite 入门教程(一)基本控制台(终端)命令
- getopt_long 与 optind
- 哲学家进餐问题
- Crypto++简要入门
- flex actionscript时间处理