Giter Site home page Giter Site logo

corefmdb's Introduction

image

OC收山之作: CoreModel Series

##CoreFMDB
.Xcode 5.0, iOS 6.0
.OC,Swift
.Under the MIT License



SERIES

    Doesn’t know how to write sql? No worries. Now the second part offers you one key 
    automatically create table, one key CURD, automatically check model and 
    dynamically add field, model cascade CURD. All these things are automatic without          
    one sql code.
    
    
    
    Due to my time constraints and ease of use these frames,
    the release cycle will be long.
    
    
    
    EN:The second part  automatically CURD release date: 21/06/2015, so stay tuned or 
    join our qq group(163865401) to get the latest news, thanks a lot.



EN:I am Charlin Feng, a developer from Chengdu, China. The true spirit of open source is an attitude and sharing even a challenge to the traditional way. There is no flaunt, pretentious or money but all my spirits which need your support.


The core purpose of these series frames is replace to Core Data and implement one key Dynamic Cache. This is the first frame with other three followed. You are gonna ask me why make these frame so separately. Even some of my friends blame me at the “chaos” of my projects’ structure. Actually, it’s due to I got a magnificent frame in all my frameworks with a core purpose which is decoupling. Because I believe that I will try my best to separate it if it’s a function module. I feel I benefit from the core idea of decoupling. I hope you guys could understand. Thank you very much.



DEPENDENCE

.FMDB

USAGE

This frame is based on FMDB and it’s static package, all classes method call, thread-safe at the same time. You don’t need to create datebase object, instance or record. It’s a green, simple and good frame.


1. Introduced header

  #import "CoreFMDB.h"

2. the method of the update statement

    /**
     *  执行一个更新语句
     *
     *  @param sql 更新语句的sql
     *
     *  @return 更新语句的执行结果
     */
    +(BOOL)executeUpdate:(NSString *)sql;

3. the method of search statement

    /**
     *  执行一个查询语句
     *
     *  @param sql              查询语句sql
     *  @param queryResBlock    查询语句的执行结果
     */
    +(void)executeQuery:(NSString *)sql queryResBlock:(void(^)(FMResultSet *set))queryResBlock;

5. Truncate your table

/**
*  清空表(但不清除表结构)
*
*  @param table 表名
*
*  @return 操作结果
*/
+(BOOL)truncateTable:(NSString *)table;

5. get the recored count of table

    /**
     *  表记录数计算
     *
     *  @param table 表
     *
     *  @return 记录数
     */
    +(NSUInteger)countTable:(NSString *)table;

6. get all the rows of the table

    /**
     *  查询出指定表的列
     *
     *  @param table table
     *
     *  @return 查询出指定表的列的执行结果
     */
    +(NSArray *)executeQueryColumnsInTable:(NSString *)table;


EXAMPLE

    BOOL res =  [CoreFMDB executeUpdate:@"create table if not exists user(id integer primary key autoIncrement,name text not null default '',age integer not null default 0);"];
    
    if(res){
        NSLog(@"创表执行成功 create table succeed");
    }else{
        NSLog(@"创表执行失败 create table fails");
    }

    

    BOOL res2= [CoreFMDB executeUpdate:@"insert into user (name,age) values('jack',27);"];

    if(res2){
        NSLog(@"添加数据成功 add data succeed");
    }else{
        NSLog(@"添加数据失败 add data fails");
    }

    

    NSArray *columns = [CoreFMDB executeQueryColumnsInTable:@"user"];
    
    NSLog(@"列信息:%@",columns);


    [CoreFMDB executeQuery:@"select * from user;" queryResBlock:^(FMResultSet *set) {
        
        while ([set next]) {
            NSLog(@"%@-%@",[set stringForColumn:@"name"],[set stringForColumn:@"age"]);
        }
        
    }];
    
    
    
    NSUInteger count = [CoreFMDB countTable:@"user"];
    
    NSLog(@"当前有%@条记录",@(count));




Career

Charlin's Career

WebSite:http://ios-android.cn
Sina WeiBo:http://weibo.com/charlin2015/


CoreModel Series

One:CoreFMDB https://github.com/nsdictionary/CoreFMDB

Two:CoreArchive https://github.com/nsdictionary/CoreArchive

Three:CoreModel https://github.com/nsdictionary/CoreClass

corefmdb's People

Contributors

charlinfeng avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

corefmdb's Issues

批量插入数据

两个问题
1。所有的操作一定得在主线程吗?用子线程会不会有什么问题?
2。批量插入数据的时候没有使用事务的吗?

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.