sqlite3_get_table
定义如下:
int sqlite3_get_table(
sqlite3 *db, /* An open database */
const char *zSql, /* SQL to be evaluated */
char ***pazResult, /* Results of the query */
int *pnRow, /* Number of result rows written here */
int *pnColumn, /* Number of result columns written here */
char **pzErrmsg /* Error msg written here */
);
如文档中所述,它可以方便地获取结果表,并作为 sqlite3_exec() 的包装器实现。
但现在不推荐:
This is a legacy interface that is preserved for backwards compatibility. Use of this interface is not recommended.
但是如果我使用sqlite3_exec
,我需要额外写一个回调函数。比较复杂。
所以我的问题是这个接口(interface)的主要问题是什么?为什么需要弃用它?
有关详细信息,请参阅 http://www.sqlite.org/c3ref/free_table.html .
最佳答案
sqlite3_get_table
的问题是所有值都转换为字符串,并且必须为所有结果记录分配内存。
你应该使用 sqlite3_prepare_v2/sqlite3_step/sqlite3_column_xxx/sqlite3_finalize功能。
关于c++ - 为什么不推荐SQLite C接口(interface)中的接口(interface)sqlite3_get_table,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15127029/