<commit_before># LKDBSearchHelper



#####说明
* 鉴于移动端不应该存在过于复杂的查询 暂时不支持 have ， join  语法
* 完全屏蔽底层API,方便后续替换



#####引用

	source 'https://github.com/CocoaPods/Specs.git'
	source 'https://github.com/junhaiyang/Specs.git'
	 
    pod 'LKDBSearchHelper', '~> 1.0'

#####表例子

		
	#import "LKDBSearchHelper.h"
	
	@interface TestObj:LKDBPersistenceObject
	
	@property (nonatomic,strong) NSString *name;
	@property (nonatomic,assign) int key;
	@property (nonatomic,strong) NSString *ads;
	
	@end
	
	
	@implementation TestObj
	
	
	+ (NSArray *)transients{
		return @[@"ads"];  //忽略不存库
	}
	
	@end
	
	
#####使用例子


    //生成查询，基本定义了几种类型
    
    // SELECT* FROM TestObj WHERE name='11122' AND key=123
   	LKDBSelect *select = [[[[LKDBSQLite select] from:[TestObj class]]
      where:LKDB_NotEqual_String(@"name",@"11122")]
    and:LKDB_NotEqual_Int(@"key", 123)]
                         ;
    
    NSLog(@"%@",[select getQuery]);
    
    
    // OR name='ssss' 
    [select or:LKDB_Equal_String(@"name", @"ssss")];
    
    NSLog(@"%@",[select getQuery]);
                               
    
    //生成一个AND包含条件: AND ( ...... ) 格式
    LKDBConditionGroup *andConditionGroup =[select innerAndConditionGroup];
    
    //  AND ( key=3322 OR key=8899 ) 
    [[innerAndConditionGroup where:LKDB_Equal_Int(@"key", 3322)]
      or:LKDB_Equal_Int(@"key", 8899)]];
      
    //再生成一个 OR 包含条件: OR ( ...... ) 格式
    LKDBConditionGroup *orConditionGroup =[select innerOrConditionGroup];
    
    //  OR ( key=3322 OR key=8899 ) 
    [[innerOrConditionGroup where:LKDB_Equal_Int(@"key", 3322)]
      or:LKDB_Equal_Int(@"key", 8899)]];
      
      
    //在包含条件里面再生成一个 OR 包含条件: OR ( ...... ) 格式
    LKDBConditionGroup *innerOrConditionGroup2 =[innerOrConditionGroup innerOrConditionGroup];
    
    //  OR ( key=3322 OR key=8899 ) 
    [[innerOrConditionGroup2 where:LKDB_Equal_Int(@"key", 3322)]
      or:LKDB_Equal_Int(@"key", 8899)]];
    
    NSLog(@"%@",[select getQuery]);
    
    //最小结果 结果偏移
    // LIMIT 5,5 
    [[select offset:5] limit:5];
    
    NSLog(@"%@",[select getQuery]); 
    
     //查询总数
    int count =[select queryCount];
    
     //查询多个结果
    NSArray* list = [select queryList];
    
     //查询单个结果
    TestObj *obj =[select querySingle];
    
    
    
     //事物操作
    [LKDBSQLite executeForTransaction:^BOOL(void) {
        
        [[LKDBSQLite select] from:[TestObj class]] .........
        
        return YES; //YES 为提交事务，NO 取消事务
    }];
    
    
    
    //保存
     TestObj *new_obj =[TestObj new];
     new_obj =@"1212";
     [new_obj saveToDB];
     
    //更新：被更新的对象必须是通过查询得到的
     TestObj *obj =[select querySingle];
     obj.name =@"1212";
     [obj updateToDB];
     
    //删除：被删除的对象必须是通过查询得到的
     TestObj *obj =[select querySingle];
     [obj deleteToDB];
    
    //删除表
     [TestObj dropToDB];
    
#####条件说明

		
		
	//基本条件语句

	//条件等于
	LKDB_Equal_String(name,value)   
 	LKDB_Equal_Int(name,value)     
	LKDB_Equal_Float(name,value)        



	//条件不等于
	LKDB_NotEqual_String(name,value)    
	LKDB_NotEqual_Int(name,value)        
	LKDB_NotEqual_Float(name,value)     



	//字符串 IS NOT
	LKDB_IsNot_String(name,value)     
	//字符串LIKE
	LKDB_LIKE_String(name,value)         

	//条件小于
	LKDB_LessThan_String(name,value)   
	LKDB_LessThan_Int(name,value)        
	LKDB_LessThan_Float(name,value)    

	//条件大于
	LKDB_GreaterThan_String(name,value)        
	LKDB_GreaterThan_Int(name,value)      
	LKDB_GreaterThan_Float(name,value)       

	//条件小于等于
	LKDB_LessAndEqualThan_String(name,value) 
	LKDB_LessAndEqualThan_Int(name,value)            
	LKDB_LessAndEqualThan_Float(name,value)    

	//条件大于等于
	LKDB_GreaterAndEqualThan_String(name,value)             
	LKDB_GreaterAndEqualThan_Int(name,value)           
	LKDB_GreaterAndEqualThan_Float(name,value)         
	                  

	//IN条件 
	LKDB_IN_String(name,values)    
	LKDB_IN_Int(name,values)   
	
	

	//基本条件
	LKDB_Condition(name,operation,value)    //value 是String ，如果是处理字符串 得加上单引号和转义,数字类型就直接生成String 就可以    
<commit_msg>add readme<commit_after># LKDBSearchHelper



#####说明
* 鉴于移动端不应该存在过于复杂的查询 暂时不支持 have ， join  语法
* 完全屏蔽底层API,方便后续替换
* 支持swift编译调用



#####引用

	source 'https://github.com/CocoaPods/Specs.git'
	source 'https://github.com/junhaiyang/Specs.git'
	 
    pod 'LKDBSearchHelper', '~> 1.0'

#####表例子

		
	#import "LKDBSearchHelper.h"
	
	@interface TestObj:LKDBPersistenceObject
	
	@property (nonatomic,strong) NSString *name;
	@property (nonatomic,assign) int key;
	@property (nonatomic,strong) NSString *ads;
	
	@end
	
	
	@implementation TestObj
	
	
	+ (NSArray *)transients{
		return @[@"ads"];  //忽略不存库
	}
	
	@end
	
#####model操作例子
	
	
    //保存
     TestObj *new_obj =[TestObj new];
     new_obj =@"1212";
     [new_obj saveToDB];
     
    //更新：被更新的对象必须是通过查询得到的
     TestObj *obj =[select querySingle];
     obj.name =@"1212";
     [obj updateToDB];
     
    //删除：被删除的对象必须是通过查询得到的
     TestObj *obj =[select querySingle];
     [obj deleteToDB];
    
    //删除表
     [TestObj dropToDB];
	
#####查询条件例子


    //生成查询，基本定义了几种类型
    
    // SELECT* FROM TestObj WHERE name='11122' AND key=123
   	LKDBSelect *select = [[[[LKDBSQLite select] from:[TestObj class]]
      where:LKDB_NotEqual_String(@"name",@"11122")]
    and:LKDB_NotEqual_Int(@"key", 123)]
                         ;
    
    NSLog(@"%@",[select getQuery]);
    
    
    // OR name='ssss' 
    [select or:LKDB_Equal_String(@"name", @"ssss")];
    
    NSLog(@"%@",[select getQuery]);
                               
    
    //生成一个AND包含条件: AND ( ...... ) 格式
    LKDBConditionGroup *andConditionGroup =[select innerAndConditionGroup];
    
    //  AND ( key=3322 OR key=8899 ) 
    [[innerAndConditionGroup where:LKDB_Equal_Int(@"key", 3322)]
      or:LKDB_Equal_Int(@"key", 8899)]];
      
    //再生成一个 OR 包含条件: OR ( ...... ) 格式
    LKDBConditionGroup *orConditionGroup =[select innerOrConditionGroup];
    
    //  OR ( key=3322 OR key=8899 ) 
    [[innerOrConditionGroup where:LKDB_Equal_Int(@"key", 3322)]
      or:LKDB_Equal_Int(@"key", 8899)]];
      
      
    //在包含条件里面再生成一个 OR 包含条件: OR ( ...... ) 格式
    LKDBConditionGroup *innerOrConditionGroup2 =[innerOrConditionGroup innerOrConditionGroup];
    
    //  OR ( key=3322 OR key=8899 ) 
    [[innerOrConditionGroup2 where:LKDB_Equal_Int(@"key", 3322)]
      or:LKDB_Equal_Int(@"key", 8899)]];
    
    NSLog(@"%@",[select getQuery]);
    
    //最小结果 结果偏移
    // LIMIT 5,5 
    [[select offset:5] limit:5];
    
    NSLog(@"%@",[select getQuery]); 
    
     //查询总数
    int count =[select queryCount];
    
     //查询多个结果
    NSArray* list = [select queryList];
    
     //查询单个结果
    TestObj *obj =[select querySingle];
    
     
     
#####删除条件使用例子


    //生成查询，基本定义了几种类型
    
    // DELETE FROM TestObj WHERE name='11122' AND key=123
   	LKDBDelete *select = [[[[LKDBSQLite delete] from:[TestObj class]]
      where:LKDB_NotEqual_String(@"name",@"11122")]
    and:LKDB_NotEqual_Int(@"key", 123)]
                         ;
    
    NSLog(@"%@",[select getQuery]);
    
    
    // OR name='ssss' 
    [select or:LKDB_Equal_String(@"name", @"ssss")];
    
    NSLog(@"%@",[select getQuery]);
                               
    
    //生成一个AND包含条件: AND ( ...... ) 格式
    LKDBConditionGroup *andConditionGroup =[select innerAndConditionGroup];
    
    //  AND ( key=3322 OR key=8899 ) 
    [[innerAndConditionGroup where:LKDB_Equal_Int(@"key", 3322)]
      or:LKDB_Equal_Int(@"key", 8899)]];
      
    //再生成一个 OR 包含条件: OR ( ...... ) 格式
    LKDBConditionGroup *orConditionGroup =[select innerOrConditionGroup];
    
    //  OR ( key=3322 OR key=8899 ) 
    [[innerOrConditionGroup where:LKDB_Equal_Int(@"key", 3322)]
      or:LKDB_Equal_Int(@"key", 8899)]];
      
      
    //在包含条件里面再生成一个 OR 包含条件: OR ( ...... ) 格式
    LKDBConditionGroup *innerOrConditionGroup2 =[innerOrConditionGroup innerOrConditionGroup];
    
    //  OR ( key=3322 OR key=8899 ) 
    [[innerOrConditionGroup2 where:LKDB_Equal_Int(@"key", 3322)]
      or:LKDB_Equal_Int(@"key", 8899)]];
    
    NSLog(@"%@",[select getQuery]);
     
    
    NSLog(@"%@",[select getQuery]);  
    
     //执行删除
     [select execute]; 
    
    
    
    
     
#####事物操作例子
	
	
     //事物操作
    [LKDBSQLite executeForTransaction:^BOOL(void) {
        
        [[LKDBSQLite select] from:[TestObj class]] .........
        
        return YES; //YES 为提交事务，NO 取消事务
    }];
    
    或
     
     //事物操作
    [[LKDBSQLite transaction] executeForTransaction:^BOOL(void) {
        
        [[LKDBSQLite select] from:[TestObj class]] .........
        
        return YES; //YES 为提交事务，NO 取消事务
    }];
    
    线性操作
    
    LKDBTransaction * transaction = [LKDBSQLite transaction];
    
    [transaction  update:obj];
    [transaction  insert:obj];
    [transaction  delete:obj];
    
    [transaction  updateAll:objs];
    [transaction  insertAll:objs];
    [transaction  deleteAll:objs];
    
    [transaction execute];  //会严格按照操作调用顺序执行
     
    
    
#####条件说明

		
		
	//基本条件语句

	//条件等于
	LKDB_Equal_String(name,value)   
 	LKDB_Equal_Int(name,value)     
	LKDB_Equal_Float(name,value)        



	//条件不等于
	LKDB_NotEqual_String(name,value)    
	LKDB_NotEqual_Int(name,value)        
	LKDB_NotEqual_Float(name,value)     



	//字符串 IS NOT
	LKDB_IsNot_String(name,value)     
	//字符串LIKE
	LKDB_LIKE_String(name,value)         

	//条件小于
	LKDB_LessThan_String(name,value)   
	LKDB_LessThan_Int(name,value)        
	LKDB_LessThan_Float(name,value)    

	//条件大于
	LKDB_GreaterThan_String(name,value)        
	LKDB_GreaterThan_Int(name,value)      
	LKDB_GreaterThan_Float(name,value)       

	//条件小于等于
	LKDB_LessAndEqualThan_String(name,value) 
	LKDB_LessAndEqualThan_Int(name,value)            
	LKDB_LessAndEqualThan_Float(name,value)    

	//条件大于等于
	LKDB_GreaterAndEqualThan_String(name,value)             
	LKDB_GreaterAndEqualThan_Int(name,value)           
	LKDB_GreaterAndEqualThan_Float(name,value)         
	                  

	//IN条件 
	LKDB_IN_String(name,values)    
	LKDB_IN_Int(name,values)   
	
	

	//基本条件
	LKDB_Condition(name,operation,value)    //value 是String ，如果是处理字符串 得加上单引号和转义,数字类型就直接生成String 就可以    

{'fraction_non_alphanumeric': 0.1379858832885973, 'fraction_numerical': 0.022467442091659212, 'mean_word_length': 2.4665747760165404, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, 'https://': 4, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5461719', 'n_tokens_mistral': 4401, 'n_tokens_neox': 4180, 'n_words': 584}