GithubHelp home page GithubHelp logo

db's Introduction

DB

方便使用数据库的一个封装,需要依赖FMDB第三方

//创建表
    DBTable *table = [[DBTable alloc] initWithTableName:@"test6" withPropertyClass:TestTableModel.class];
    
    //需要储存的数据模型
    TestTableModel *model = [[TestTableModel alloc] init];
    model.size = 1;
    model.flo = 0.12f;
    model.isLoad = YES;
    model.dict = [NSDictionary dictionaryWithObjectsAndKeys:@"jieguo",@"key", nil];
    model.array = [NSMutableArray arrayWithObjects:@"1",@"3",@"5", nil];
    model.path = @"path";
    model.tableUpload = @"测试升级";
    [table insertModel:model];
    
    //获取数据库数据
    NSArray *array = [table getDataList];
    
    //遍历
    for (int i = 0; i < array.count; i++) {
        TestTableModel *model = array[i];
        NSLog(@"%f",model.flo);
        NSLog(@"%d",model.size);
        NSLog(@"%@",model.path);
        NSLog(@"%@",model.array);
        NSLog(@"%ld",model.identifie);
    }
    
    //修改第一个的值
    TestTableModel *firstModel = [array firstObject];
    firstModel.flo = 0.13;
    firstModel.size = 10;
    firstModel.path = @"uploadpath";
    firstModel.array = [NSMutableArray arrayWithObjects:@"3",@"4",@"5", nil];
    [table updateModel:firstModel];
    
    array = [table getDataList];
    
    //遍历
    for (int i = 0; i < array.count; i++) {
        TestTableModel *model = array[i];
        NSLog(@"%f",model.flo);
        NSLog(@"%d",model.size);
        NSLog(@"%@",model.path);
        NSLog(@"%@",model.array);
        NSLog(@"%ld",model.identifie);
    }
    
    //删除第一个数据
    TestTableModel *secModel = [array objectAtIndex:0];
    [table deleteModelOf:secModel.identifie];
    
    array = [table getDataList];
    
    //遍历
    for (int i = 0; i < array.count; i++) {
        TestTableModel *model = array[i];
        NSLog(@"%f",model.flo);
        NSLog(@"%d",model.size);
        NSLog(@"%@",model.path);
        NSLog(@"%@",model.array);
        NSLog(@"%ld",model.identifie);
    }

db's People

Contributors

suoxiaoxiao avatar

Watchers

James Cloos avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.