Database
Sql
SQL is a tool for organizing, managing, and retrieving data stored in a computer database
SQL is the full write of SQL that is Structured Query Language (structured query Language)
DDL (data definition language)
Data definition SQL lets you define the structure and organization of stored data, and the relationships between stored data items
Data retrieval SQL allows a user or application to retrieve stored data from the library and use it
DML (Data Management language)
Data manipulation SQL allows a user or application to update a database by adding new data, deleting old data, and modifying previously stored data
The following functions are available in the database
1, query the contents of the database
Select field name, field name ..... Table name in from database
Query all the information in the table:
Select *form Table name example: int result = Sqlite3_prepare (db, "select * from Class18",-1, &stmt, NULL);
Specify the query:
where Field name = "" (condition) Example: int result = Sqlite3_prepare (db, "select *from class18 where _id =?")
2. Modification of data
Update table name set field name WHERE Condition example: int result = Sqlite3_prepare (db, "update class set _sex =?, _phone =?") where _id =? ",-1, &stmt, NULL);
3, the deletion of data
Drop Table table name (field description) Example: int result = Sqlite3_prepare (db, "delete from class18 where _id =?",-1, &stmt, NULL);
4. Insertion/addition of data
Insert into table name (field name, field name ...) Values (value, value, value): )
or insert into table name values (Value ... ) is consistent with the build table order
Example: int result = Sqlite3_prepare (db, "Insert info Class18 (_name,_sex,_age) VALUES (?,?,?)", 1, &stmt, NULL);
Database integrity SQL defines integrity constraints in the database so that he does not hesitate for inconsistent updates or system failures to be compromised
Common Properties for SQL
Sqlite_open () Open database
Sqlite_close () Close the database
SQLITE_PREPARE_V2 () to execute the SQL statement, you must first compile it into bytecode, and the prepare function is responsible for the SQL statement
Sqlite_step () After compiling the SQL statement using prepare, you can use the step function to perform
Sqlite_column () for select Fisheries, after running with Sqlite3_step, the results need to be read out
Sqlite3_finalize () sqlite3_stmt used, sqlite3_finalize () to destroy the SQLITE3_STMT, the function must be called after the end of the use of sqlite3_stmt, otherwise it will cause memory leaks
Sqlite3_bind_xxx () Depending on the type of data you want to use, you can choose a different binding statement
Note: To use SQL in your project you need to introduce a framework libsqlite3.dylib also include header files in the class where you want to use the database sqlite3.h
Specific methods
1. Select your own project
2. Select target
3. Go to build phases Select camera
4. Expand link Binary with Libraries drop-down triangle
5. Click + to add the frame you want to join