我如何NSLog记录' indays'来自下面的SQLite查询的变量?
以下是查询:
select data1,display_name,
((strftime('%s',strftime('%Y', 'now','localtime')||strftime('-%m-%d', data1))-strftime('%s','now','localtime'))/86400.0+1+((strftime('%s','now', 'localtime','+1 year')-strftime('%s','now', 'localtime'))/86400.0)) % ((strftime('%s','now', 'localtime','+1 year')-strftime('%s','now', 'localtime'))/86400.0) as indays
from contact_birthday
order by indays asc
答案 0 :(得分:0)
[阅读sqlite3文档],尤其是C/C++ Reference。
使用sqlite3_column_XXX(..., ...);
函数读取列的值。
sqlite3_stmt* selectStmt;
sqlite3_prepare_v2(yourdb, "SELECT ...", -1, &selectStmt, NULL);
while(SQLITE_ROW == sqlite3_step(selectStmt)) {
const unsigned char* txt = sqlite3_column_text(selectStmt, 3); // get 3rd column text
NSString* indays = [NSString stringWithCString:txt encoding:NSASCIIStringEncoding];
}
sqlite3_finalize(selectStmt);