iOS SQLite函数总结
1.打開數據庫
int sqlite3_open(
? ? const char *filename, ? // 數據庫的文件路徑
? ? sqlite3 **ppDb? ? ? ? ? // 數據庫實例
);
?
2.執行任何SQL語句
int sqlite3_exec(
? ? sqlite3*,? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? // 一個打開的數據庫實例
? ? const char *sql, ? ? ? ? ? ? ? ? ? ? ? ? ? // 需要執行的SQL語句
? ? int (*callback)(void*,int,char**,char**),? // SQL語句執行完畢后的回調
? ? void *,? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? // 回調函數的第1個參數
? ? char **errmsg? ? ? ? ? ? ? ? ? ? ? ? ? ? ? // 錯誤信息
);
?
3.檢查SQL語句的合法性(查詢前的準備)
int sqlite3_prepare_v2(
? ? sqlite3 *db,? ? ? ? ? ? // 數據庫實例
? ? const char *zSql, ? ? ? // 需要檢查的SQL語句
? ? int nByte,? ? ? ? ? ? ? // SQL語句的最大字節長度
? ? sqlite3_stmt **ppStmt,? // sqlite3_stmt實例,用來獲得數據庫數據
? ? const char **pzTail
);
?
4.查詢一行數據
int sqlite3_step(sqlite3_stmt*); // 如果查詢到一行數據,就會返回SQLITE_ROW
?
5.利用stmt獲得某一字段的值(字段的下標從0開始)
double sqlite3_column_double(sqlite3_stmt*, int iCol);? // 浮點數據
int sqlite3_column_int(sqlite3_stmt*, int iCol); // 整型數據
sqlite3_int64 sqlite3_column_int64(sqlite3_stmt*, int iCol); // 長整型數據
const void *sqlite3_column_blob(sqlite3_stmt*, int iCol); // 二進制文本數據
const unsigned char *sqlite3_column_text(sqlite3_stmt*, int iCol);? // 字符串數據
轉載于:https://www.cnblogs.com/endtel/p/4839837.html
總結
以上是生活随笔為你收集整理的iOS SQLite函数总结的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: ArrayList 的实现原理
- 下一篇: background意识(两)