123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211 |
- //
- // YDFMDB.h
- // YUEDU
- //
- // Created by jcymac on 2017/12/6.
- // Copyright © 2017年 kuxuan. All rights reserved.
- //
- #import <Foundation/Foundation.h>
- @interface YDFMDB : NSObject
- /**
- //单例
- @return 单例对象
- */
- +(instancetype)sharedInstance;
- /**
- 执行sql语句
- @param sql sql语句
- @return 是否执行成功
- */
- -(BOOL)executeUpdateByString:(NSString *)sql;
- /**
- //创建表
- @param tableName 表名称
- 例:@"jcytable"
-
- @param fieldNamesDictionaryArray 字典数组 字典两个键值对,两个key是@"name"和@"type",值是NSString
- 例:@[@{@"name":@"id",@"type":"integer"},
- @{@"name":@"name",@"type":"text"}]
-
- @return 创建成功返回YES 失败返回NO
- */
- - (BOOL)createTableName:(NSString *)tableName fieldNamesDictionaryArray:(NSArray*)fieldNamesDictionaryArray;
- /**
- DROP TABLE
- @param tableName 表名称
- @return 删除成功返回YES 失败返回NO
- */
- -(BOOL)dropTableByTableName:(NSString *)tableName;
- /**
- //添加字段
-
- @param fieldNamesDictionaryArray 字典数组 字典两个键值对,两个key是@"name"和@"type",值是NSString
- 例:@[@{@"key":@"id",@"value":"integer"},
- @{@"key":@"name",@"value":"text"}]
-
- @param tableName 表名称
- 例:@"jcytable"
-
- @return 添加字段成功返回YES 失败返回NO
- */
- - (BOOL)addFieldNamesDictionaryArray:(NSArray*)fieldNamesDictionaryArray withTableName:(NSString *)tableName;
- /**
- //删除字段
- sqlite不支持删除字段
- @param fieldNamesStringArray 字符串数组 要删除的字段名称
- 例:@[@"id",@"name"]
-
- @param tableName 表名称
- 例:@"jcytable"
-
- @return 删除字段成功返回YES 失败返回NO
- */
- //- (BOOL)deleteFieldNamesStringArray:(NSArray*)fieldNamesStringArray withTableName:(NSString *)tableName;
- /**
- //增加数据 传递NSArray(key value)
- @param dataStringDictionary 要添加的字典 key是列名 value是数据
- 例:@{@"id":@"1",@"name",@"贾创业"}
-
- @param tableName 表名称
- 例:@"jcytable"
-
- @return 增加数据成功返回YES 失败返回NO
- */
- - (BOOL)addSingleDataStringDictionary:(NSDictionary *)dataStringDictionary withTableName:(NSString *)tableName;
- /**
- //删除数据 key value
- @param conditionStringDictionary (条件) 字典 key是列名 value是数据
- 例:@{@"id":@"1",@"name",@"贾创业"}
-
- @param tableName 表名称
- 例:@"jcytable"
-
- @return 删除数据成功返回YES 失败返回NO
- */
- - (BOOL)deleteDataByEqualConditionStringDictionary:(NSDictionary *)conditionStringDictionary withTableName:(NSString *)tableName;
- /**
- //删除数据
- @param conditionString 条件字符串
- 例:@" id=1 and name='贾创业' "
- 注意:字符串用单引号
-
- @param tableName 表名称
- 例:@"jcytable"
-
- @return 删除数据成功返回YES 失败返回NO
- */
- - (BOOL)deleteDataByConditionString:(NSString *)conditionString withTableName:(NSString *)tableName;
- /**
- //更改数据 key value 更改的字段字典 条件
-
- @param conditionStringDictionary (条件) 字典 key是列名 value是数据
- 例:@{@"id":@"1",@"name",@"贾创业"}
-
-
- @param newStringDictionary (新数据) 要设置的字典数组 key是列名 value是数据
- 例:@{@"id":@"999",@"name",@"jcy"}
- @param tableName 表名称
- 例:@"jcytable"
-
- @return 更改数据成功返回YES 失败返回NO
- */
- - (BOOL)changeDataByEqualConditionStringDictionary:(NSDictionary *)conditionStringDictionary withNewStringDictionary:(NSDictionary *)newStringDictionary withTableName:(NSString *)tableName;
- /**
- //更改数据
- @param conditionString 条件字符串
- 例:@" id=1 or name='贾创业' "
-
- @param newString 新的数据字符串
- 例:@" id=999,name='jcy' "
- 注意:字符串用单引号
-
- @param tableName 表名称
- 例:@"jcytable"
-
- @return 更改数据成功返回YES 失败返回NO
- */
- - (BOOL)changeDataByConditionString:(NSString *)conditionString withNewString:(NSString *)newString withTableName:(NSString *)tableName;
- /**
- //查询数据 传递NSArray(key value)
- @param conditionStringDictionary (条件) 字典 key是列名 value是数据
- 例:@{@"id":@"1",@"name",@"贾创业"}
-
- @param selectStringArray (查询) 要查询的的字符串数组
- 例:@[@"id",@"name"]
-
- @param tableName 表名称
- 例:@"jcytable"
-
- @param limit 限制
- 例:0
-
- @return 键值对字典数组 一个字典一行数据
- */
- - (NSArray *)selectDataByEqualConditionStringDictionary:(NSDictionary *)conditionStringDictionary withSelectStringArray:(NSArray *)selectStringArray withTableName:(NSString *)tableName limit:(NSInteger)limit descID:(BOOL)descID;
- /**
- 查询数据
- @param conditionString 条件字符串
- 例:@" id<1 and name='贾创业'"
- 注意:字符串用单引号
-
- @param selectStringArray (查询) 要查询的的字符串数组
- 例:@[@"id",@"name"]
-
- @param tableName 表名称
- 例:@"jcytable"
-
- @param limit 限制
- 例:0
-
- @return 键值对字典数组 一个字典一行数据
- */
- - (NSArray *)selectDataByConditionString:(NSString *)conditionString withSelectStringArray:(NSArray *)selectStringArray withTableName:(NSString *)tableName limit:(NSInteger)limit descID:(BOOL)descID;
- @end
|