当前位置:Gxlcms > 数据库问题 > sqlite3入门之sqlite3_get_table,sqlite3_free_table

sqlite3入门之sqlite3_get_table,sqlite3_free_table

时间:2021-07-01 10:21:17 帮助过:4人阅读

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 */ ); void sqlite3_free_table(char **result);
  • sqlite3_get_table主要是用于非回调的方式进行select查询,参数如下;
  • 参数1:打开数据库得到的指针;
  • 参数2:一条sql语句,跟sqlite3_exec中一样;
  • 参数3:查询的数据结果,他是一个指针数组,内存分布为:字段名称,后面是紧接着是每个字段的值;
  • 参数4:查询到的数据条数,(行数);
  • 参数5:查询到的字段数,(列数);
  • 参数6:错误信息;
  • void main(void) {
       ......
       rc = sqlite3_get_table(db, "SELECT * FROM RELAY", &dbresult, &nRow, &nColum, &zErrMsg);
        if(rc == SQLITE_OK) {
            index = nColum;
            for(i = 0; i < nRow; i++) {
                for(j = 0; j < nColum; j++) {
                    printf("zidanming:%s, ziduanzhi:%s\n", dbresult[j], dbresult[index]);
                     ++index;
                }
            }
        }
    sqlite3_free_table(dbresult);

    ......
    } 
  • sqlite3_free_table

    • 用于释放保存查询内容的指针数组;

    sqlite3入门之sqlite3_get_table,sqlite3_free_table

    标签:eva   int   信息   query   base   select   main   from   open   

    人气教程排行