IOS之数据库的查找,删除,添加,更新(5)
来源:未知 责任编辑:责任编辑 发表时间:2013-12-22 14:54 点击:次
+(void)deleteByID:(int)ID
{
NSString *str = [NSString stringWithFormat:@"delete from classDB where ID = %d",ID];
sqlite3 *db = [DB openDB];
sqlite3_stmt *stmt = nil;
int result = sqlite3_prepare_v2(db, [str UTF8String], -1, &stmt, nil);
if (result == SQLITE_OK)
{
sqlite3_step(stmt);
}
sqlite3_finalize(stmt);
}
//更新
+(void)updataName:(NSString *)name phone:(NSString *)phone age:(int)age forID:(int)ID
{
NSString *str = [NSString stringWithFormat:@"update classDB set name = '%@',phone = '%@',age = %d where ID = %d",name,phone,age,ID];
sqlite3 *db = [DB openDB];
sqlite3_stmt *stmt = nil;
int result = sqlite3_prepare_v2(db, [str UTF8String], -1, &stmt, nil);
if (result == SQLITE_OK)
{
sqlite3_step(stmt);
}
sqlite3_finalize(stmt);
}
@end
相关新闻>>
- 发表评论
-
- 最新评论 更多>>