1. Using Dependency relationships
A, you need to add libsqlite3.tbd static library.
b, need to add third-party framework FMBD, Mjextension.
2. SQL statement Class package name Databasesqltool
Class method Description:
/**
* Delete Table
*
* @param tableName Data Sheet name
*
* @return Delete Table is successful
*/
+ (BOOL) deletetable: (NSString *) tableName;
/**
* Clear the table (empty the contents of the table)
*
* @param tableName Data Sheet name
*
* @return Clear if the table is successful
*/
+ (BOOL) erasetable: (NSString *) tableName;
/**
* Determine if a table exists
*
* @param tableName Data Sheet name
*
* @return
*/
+ (BOOL) Istableok: (NSString *) tableName;
/**
* Create a table
*
* @param tableName Data Sheet name
* @param sqlstatement Table Properties (SQL statement)
*
* @return The creation of the table is successful
* SQL Statement Example: @ "CREATE TABLE IF not EXISTS t_home_status (ID integer PRIMARY KEY autoincrement, access_token text not NULL, s Tatus_idstr text NOT NULL, status_dict blob not null); "
*/
+ (BOOL) Createwithtablename: (NSString *) tableName SQLStatement: (nsstring*) SQLStatement;
/**
* Insert Data
*
* @param tableName Data Sheet name
* @param sqlstatement inserted properties and VALUES (SQL statement)
*
* @return Insert Data is successful
* SQL Statement Example: @ "INSERT into TableName (name,age) VALUES (' Lisi ', ' 28 ')"
*/
+ (BOOL) Insertwithtablename: (NSString *) tableName SQLStatement: (nsstring*) SQLStatement;
/**
* Delete Data
*
* @param tableName Data Sheet name
* @param deletewhere Delete condition (SQL statement)
*
* @return Delete Data is successful
* SQL Statement Example: @ "Delete from TableName (data table) where name= ' Lisi '";
*/
+ (BOOL) Deletewithtablename: (NSString *) tableName deletewhere: (NSString *) Deletewhere;
/**
* Update Data
*
* @param tableName Data Sheet name
* @param setValue Update data (SQL statement)
* @param updatewhere Update data conditions
*
* @return and new data are successful
* SQL Statement Example: @ "Update tableName (data table) set Age= '" where name= ' Lisi ' ";
*/
+ (BOOL) Updatewithtablename: (NSString *) tableName SetValue: (nsstring*) SetValue updatewhere: (NSString *) Updatewhere;
/**
* Find Data
*
* @param tableName Data Sheet name
* @param the property that Findtable needs to find the value is * indicates all properties in the lookup table
* @param findwhere Set query criteria
* @param the class name returned by the ResultClass query
* @param findresultblock Query Results
*
* @return Finding the data is successful
* Query precision Query and fuzzy query details see http://blog.163.com/ding_123com/blog/static/211752221201542942837616/
* SQLite basic Knowledge Reference HTTP://PAN.BAIDU.COM/S/1C1CHOAC
* SQLite Coding Knowledge Reference Http://pan.baidu.com/s/1jHYVBXs
* SQL Statement Example: @ "select msg from tableName (data table) where username= ' dy1 ' ORDER by time DESC LIMIT 1"
*/
+ (BOOL) Selectwithtablename: (NSString *) tableName findtable: (NSString *) findtable findwhere: (NSString *) findwhere ResultClass: (Class) ResultClass Findresultblock: (void (^) (Nsmutablearray *reslut)) Findresultblock;
/*
* Usage instructions only apply to find a single property of type double value
* Attribute Description Ibid.
*/
+ (BOOL) Selectsingledoublewithtablename: (NSString *) tableName findtable: (NSString *) findtable findwhere: (NSString *) Findwhere Indresultblock: (void (^) (Nsmutablearray *reslut)) Findresultblock;
/*
* Usage instructions only apply to find a single attribute of type int value
* Attribute Description Ibid.
*/
+ (BOOL) Selectsingleintwithtablename: (NSString *) tableName findtable: (NSString *) findtable findwhere: (NSString *) Findwhere Indresultblock: (void (^) (Nsmutablearray *)) Findresultblock;
/*
* Use instructions only apply to find the value of a single property as a string type
* Attribute Description Ibid.
*/
+ (BOOL) Selectsinglecharwithtablename: (NSString *) tableName findtable: (NSString *) findtable findwhere: (NSString *) Findwhere Indresultblock: (void (^) (Nsmutablearray *)) Findresultblock;
IOS develops encapsulation for SQL statements