iOS SQLite函數(shù)總結(jié)

//聯(lián)系人:石虎QQ: 1224614774昵稱:嗡嘛呢叭咪哄

1.打開數(shù)據(jù)庫

intsqlite3_open(

constchar*filename,//數(shù)據(jù)庫的文件路徑

sqlite3 **ppDb//數(shù)據(jù)庫實(shí)例

);

2.執(zhí)行任何SQL語句

intsqlite3_exec(

sqlite3*,//一個打開的數(shù)據(jù)庫實(shí)例

constchar*sql,//需要執(zhí)行的SQL語句

int(*callback)(void*,int,char**,char**),// SQL語句執(zhí)行完畢后的回調(diào)

void*,//回調(diào)函數(shù)的第1個參數(shù)

char**errmsg//錯誤信息

);

3.檢查SQL語句的合法性(查詢前的準(zhǔn)備)

intsqlite3_prepare_v2(

sqlite3 *db,//數(shù)據(jù)庫實(shí)例

constchar*zSql,//需要檢查的SQL語句

intnByte,// SQL語句的最大字節(jié)長度

sqlite3_stmt **ppStmt,// sqlite3_stmt實(shí)例,用來獲得數(shù)據(jù)庫數(shù)據(jù)

constchar**pzTail

);

4.查詢一行數(shù)據(jù)

intsqlite3_step(sqlite3_stmt*);//如果查詢到一行數(shù)據(jù),就會返回SQLITE_ROW

5.利用stmt獲得某一字段的值(字段的下標(biāo)從0開始)

doublesqlite3_column_double(sqlite3_stmt*,intiCol);//浮點(diǎn)數(shù)據(jù)

intsqlite3_column_int(sqlite3_stmt*,intiCol);//整型數(shù)據(jù)

sqlite3_int64 sqlite3_column_int64(sqlite3_stmt*,intiCol);//長整型數(shù)據(jù)

constvoid*sqlite3_column_blob(sqlite3_stmt*,intiCol);//二進(jìn)制文本數(shù)據(jù)

constunsignedchar*sqlite3_column_text(sqlite3_stmt*,intiCol);//字符串?dāng)?shù)據(jù)

最后編輯于
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時請結(jié)合常識與多方信息審慎甄別。
平臺聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點(diǎn),簡書系信息發(fā)布平臺,僅提供信息存儲服務(wù)。

相關(guān)閱讀更多精彩內(nèi)容

友情鏈接更多精彩內(nèi)容