中文字幕在线观看,亚洲а∨天堂久久精品9966,亚洲成a人片在线观看你懂的,亚洲av成人片无码网站,亚洲国产精品无码久久久五月天

fmdb常用操作代碼

2018-07-20    來源:open-open

容器云強(qiáng)勢上線!快速搭建集群,上萬Linux鏡像隨意使用
-(NSString *)databaseFilePath
{
    //獲取數(shù)據(jù)庫路經(jīng)
    NSString *url = [NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES)lastObject];
    NSString *fileName = [url stringByAppendingPathComponent:@"sqlTJL.sqlite"];
    return fileName;
}
 
-(void)fmdbData
{
     
    //獲取數(shù)據(jù)庫
    _db = [FMDatabase databaseWithPath:[self databaseFilePath]];
    //打開數(shù)據(jù)庫
    if ([_db open]) {
    //建表
        BOOL result = [_db executeUpdate:@"CREATE TABLE IF NOT EXISTS TJL_student(name text)"];
        if (result) {
            NSLog(@"建表成功");
        }else{
            NSLog(@"建表失敗");
        }
        [_db close];
    }
}
 
//插入數(shù)據(jù)
-(void)insetsqlto:(NSString *)string
{
    [_db open];
    if ([_db open]) {
        BOOL res = [_db executeUpdate:@"insert into TJL_student (name) VALUES(?)", string];
        if (!res) {
            NSLog(@"error");
        }else{
            NSLog(@"success to insert");
        }
        [_db close];
    }
}
//刪除數(shù)據(jù)
-(void)deleteopen:(NSString *)dataName
{
    if ([_db open]) {
        NSString *deleteSql = [NSString stringWithFormat:@"delete from TJL_student %@",dataName];
        BOOL res = [_db executeUpdate:deleteSql];
        if (!res) {
            NSLog(@"error when delete db table");
        }else{
            NSLog(@"success to delete db table");
        }
        [_db open];
    }
}
 
//修改數(shù)據(jù)
-(void)updataName:(NSString *)string
{
    if ([_db open]) {
        NSString *updatesql = [NSString stringWithFormat:@"UPDATE TJL_student'%@'",string];
        BOOL RES = [_db executeUpdate:updatesql];
        if (!RES) {
            NSLog(@"error when update db table");
        }else{
            NSLog(@"success to insert db able");
        }
        [_db close];
    }
}
 
//查詢數(shù)據(jù)
-(void)seacher:(NSString *)seaharName
{
    if ([_db open]) {
        FMResultSet *rs = [_db executeQuery:@"SELECT * FROM TJL_student"];
        while ([rs next]) {
            _Devices = [rs stringForColumn:@"name"];
            NSLog(@"is text---->>> %@",[rs stringForColumn:@"name"]);
        }
    }
}

標(biāo)簽: 數(shù)據(jù)庫

版權(quán)申明:本站文章部分自網(wǎng)絡(luò),如有侵權(quán),請聯(lián)系:west999com@outlook.com
特別注意:本站所有轉(zhuǎn)載文章言論不代表本站觀點(diǎn)!
本站所提供的圖片等素材,版權(quán)歸原作者所有,如需使用,請與原作者聯(lián)系。

上一篇:JavaScript和html5實(shí)現(xiàn)的3D玫瑰花

下一篇: android后臺發(fā)送郵件