iOS Learning notes----15/09/14

Source: Internet
Author: User

1.sqlite3 the creation order of the database:

    1. Use the C language function first [Nssearchpathfordirectoriesindomains (NSDocumentDirectory, Nsuserdomainmask, YES) Lastobject] To obtain the document directory of the database, and then through the stringByAppendingPathComponent method to splice out the database file directory;
    2. Creates a Sqlite3 pointer object and assigns a null value;
    3. Use the C language function Sqlite3_open (database directory. Utf8string, &sqlite3 pointer object);
    4. Determine whether the return value of the Open database function is SQLITE_OK by using the IF statement to determine if the opening is successful;

2.sqlite3 the order in which database tables are created:

    1. The const char *sql is created first, and the pointer object is used to hold the SQL statement;
    2. Create char *ERRORMESG = NULL;
    3. Using the C-language function sqlite3_exec (sqlite3 pointer object, SQL statement, NULL, NULL, &ERRORMESG) method to execute the SQL statement, there is also a return value of type int, which can be judged as the fourth step of creating a database. If the failure can use the%s direct printing ERRORMESG to determine success or failure;

The update of the 3.SQLITE3 database and the order of delete operations are almost the same as creating the table, just change the next statement.

The order of query statements for the 4.SQLITE3 database is more complex, as follows:

    1. Defines a const char *SQL statement;
    2. Defines a sqlite3_stmt pointer object;
    3. Use SQLITE3_PREPARE_V2 (SQLite pointer object, SQL statement, 1 (length of data, 1 is automatically calculated), stmt pointer object address, NULL) to detect the legality of SQL statements;
    4. The return value is judged correct;
    5. If correct, use while (Sqlite_step (stmt) = = Sqlite_row) to determine if a row is found;
    6. Use the Sqlite_column_ data type (Result pointer object, column number) in the loop to obtain the C language function;

5. When defining a query statement, you should change the string to the right of the equal sign. , and then use the Sqlite_bind_ data type (the result set pointer object, the index of the question mark (starting from 1), the data to be replaced, 1 (the length of the data, 1 is calculated automatically), and NULL (callback function) before executing;

Last week has been doing a little practice, a week of the interface, but also encountered some problems, but also solved a part, although the solution is a bit trickery, but I think the first solution to the problem before considering optimization is the best way to develop. Learn the logical part of practicing this week while learning.

iOS Learning notes----15/09/14

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.