Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/sql/73.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
SQLite C++;查询行-如何处理多个列 我是SQLite的新手,C++有点理解如何处理从查询返回的多行。我需要把每列int的值作为一个变量,以便以后处理它_C++_Sql_Database_Sqlite_C++11 - Fatal编程技术网

SQLite C++;查询行-如何处理多个列 我是SQLite的新手,C++有点理解如何处理从查询返回的多行。我需要把每列int的值作为一个变量,以便以后处理它

SQLite C++;查询行-如何处理多个列 我是SQLite的新手,C++有点理解如何处理从查询返回的多行。我需要把每列int的值作为一个变量,以便以后处理它,c++,sql,database,sqlite,c++11,C++,Sql,Database,Sqlite,C++11,到目前为止,我已经: sqlite3_stmt* statement; if (sqlite3_prepare_v2(getDatabase(), _sql.c_str(), -1, &statement, 0) == SQLITE_OK) { int cols = sqlite3_column_count(statement); int result = 0; while(true) { result = sq

到目前为止,我已经:

sqlite3_stmt* statement;

if (sqlite3_prepare_v2(getDatabase(), _sql.c_str(), -1, &statement, 0)
            == SQLITE_OK)
{
    int cols = sqlite3_column_count(statement);
    int result = 0;

    while(true)
    {
        result = sqlite3_step(statement);

        if(result == SQLITE_ROW)
        {
             for(int col = 0; col < cols; col++)
             {
                // go through each column and store it       
             }
        }
        else
        {
            break;
        }
    }
}
或者有没有一种方法可以通过列名来实现

还是有更好的办法呢?

我想出来了


正确的步骤是循环每一行,并使用
sqlite\u列(语句,[col\35;])

最终目标是什么?循环完成后,您希望数据最终精确到哪里,下一步如何处理?关于:列名-请参见
sqlite3\u column\u name
if (col == 0) // first column position
{
   // store it...
}
else if (col == 1) // second column position
{
    // store it...
}