久久久久久久av_日韩在线中文_看一级毛片视频_日本精品二区_成人深夜福利视频_武道仙尊动漫在线观看

<tfoot id='4pxjM'></tfoot>

    <i id='4pxjM'><tr id='4pxjM'><dt id='4pxjM'><q id='4pxjM'><span id='4pxjM'><b id='4pxjM'><form id='4pxjM'><ins id='4pxjM'></ins><ul id='4pxjM'></ul><sub id='4pxjM'></sub></form><legend id='4pxjM'></legend><bdo id='4pxjM'><pre id='4pxjM'><center id='4pxjM'></center></pre></bdo></b><th id='4pxjM'></th></span></q></dt></tr></i><div class="qwawimqqmiuu" id='4pxjM'><tfoot id='4pxjM'></tfoot><dl id='4pxjM'><fieldset id='4pxjM'></fieldset></dl></div>

    <small id='4pxjM'></small><noframes id='4pxjM'>

        <bdo id='4pxjM'></bdo><ul id='4pxjM'></ul>

    1. <legend id='4pxjM'><style id='4pxjM'><dir id='4pxjM'><q id='4pxjM'></q></dir></style></legend>

    2. 使用 MySQL C API 和 C++ 獲取 MySQL 數據庫表中的行

      Fetching rows in a MySQL database table using MySQL C API and C++(使用 MySQL C API 和 C++ 獲取 MySQL 數據庫表中的行)
      <i id='FjWyb'><tr id='FjWyb'><dt id='FjWyb'><q id='FjWyb'><span id='FjWyb'><b id='FjWyb'><form id='FjWyb'><ins id='FjWyb'></ins><ul id='FjWyb'></ul><sub id='FjWyb'></sub></form><legend id='FjWyb'></legend><bdo id='FjWyb'><pre id='FjWyb'><center id='FjWyb'></center></pre></bdo></b><th id='FjWyb'></th></span></q></dt></tr></i><div class="qwawimqqmiuu" id='FjWyb'><tfoot id='FjWyb'></tfoot><dl id='FjWyb'><fieldset id='FjWyb'></fieldset></dl></div>

      • <bdo id='FjWyb'></bdo><ul id='FjWyb'></ul>
      • <legend id='FjWyb'><style id='FjWyb'><dir id='FjWyb'><q id='FjWyb'></q></dir></style></legend>
      • <small id='FjWyb'></small><noframes id='FjWyb'>

              <tfoot id='FjWyb'></tfoot>

                  <tbody id='FjWyb'></tbody>
                本文介紹了使用 MySQL C API 和 C++ 獲取 MySQL 數據庫表中的行的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

                問題描述

                我在嘗試使用 C++ 和 MySQL C API 在 mysql 中獲取表行時感到困惑.

                I'm confused when trying to fetch table rows in mysql using C++ with MySQL C API.

                我可以在 PHP 中輕松完成,只是因為 C++ 是一種強類型語言,因此我們還需要處理骯臟的過程..

                I can do it easily in PHP, just because C++ is a strongly-typed language so that we also need to take care of the dirty process..

                這就是我在 PHP 中的做法

                This is how I done it in PHP

                $data = array();
                $i = 0;
                $query = mysql_query("SELECT * FROM `my_table`");
                while($fetch = mysql_fetch_array($query))
                {
                  $data[$i] = $fetch['columntobefetched'];
                  $i++;
                }

                但是如何在 C++ 中用 MySQL API 做同樣的事情?

                But how to do the same in C++ with MySQL API?

                到目前為止,這是我的代碼......有一個令人困惑的死胡同......x__x

                Here's my code so far....with a confusing dead end...x__x

                   MYSQL *sqlhnd = mysql_init(NULL);
                    mysql_real_connect(sqlhnd, "server", "user", "pass", "database", port, NULL, 0);
                
                    mysql_query(sqlhnd, "SELECT * FROM `my_table`");
                    MYSQL_RES *confres = mysql_store_result(sqlhnd);
                    int totalrows = mysql_num_rows(confres);
                    int numfields = mysql_num_fields(confres);
                    MYSQL_FIELD *mfield;
                
                    while((row = mysql_fetch_row(confres)))
                    {
                        for(i = 0; i < numfields; i++)
                        {
                            while(mfield = mysql_fetch_field(confres))
                            {
                                mfield->//??? I'm dead
                            }
                        }
                    }

                基本上我想從數據庫表中的一個字段中獲取一個值并將其存儲到一個變量中..

                Basically I wanted to get a value from a field in the database table and store it to a variable..

                任何形式的幫助將不勝感激:)

                Any kind of help would be appreciated :)

                謝謝

                推薦答案

                在 MySQL C API 中,mysql_fetch_row 返回一個 MYSQL_ROW 對象,它本質上是當前行中的值數組.

                In the MySQL C API, mysql_fetch_row returns a MYSQL_ROW object, which is essentially an array of values in the current row.

                因此,您的代碼應該類似于:

                So, your code should be something like:

                mysql_query(sqlhnd, "SELECT * FROM `my_table`");
                MYSQL_RES *confres = mysql_store_result(sqlhnd);
                int totalrows = mysql_num_rows(confres);
                int numfields = mysql_num_fields(confres);
                MYSQL_FIELD *mfield;
                
                while((row = mysql_fetch_row(confres)))
                {
                    for(i = 0; i < numfields; i++)
                    {
                        char *val = row[i];
                        // do something with val...
                    }
                }
                

                最好不要在程序中執行SELECT * FROM mytable".最好為您期望的字段命名,這樣您就可以確定返回的字段的順序.

                Better yet, don't do a "SELECT * FROM mytable" in a program. It would be much better to name the fields you expect, so that you can be sure of the order of the fields returned.

                這篇關于使用 MySQL C API 和 C++ 獲取 MySQL 數據庫表中的行的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!

                【網站聲明】本站部分內容來源于互聯網,旨在幫助大家更快的解決問題,如果有圖片或者內容侵犯了您的權益,請聯系我們刪除處理,感謝您的支持!

                相關文檔推薦

                How to use windowing functions efficiently to decide next N number of rows based on N number of previous values(如何有效地使用窗口函數根據 N 個先前值來決定接下來的 N 個行)
                reuse the result of a select expression in the quot;GROUP BYquot; clause?(在“GROUP BY中重用選擇表達式的結果;條款?)
                Does ignore option of Pyspark DataFrameWriter jdbc function ignore entire transaction or just offending rows?(Pyspark DataFrameWriter jdbc 函數的 ignore 選項是忽略整個事務還是只是有問題的行?) - IT屋-程序員軟件開發技
                Error while using INSERT INTO table ON DUPLICATE KEY, using a for loop array(使用 INSERT INTO table ON DUPLICATE KEY 時出錯,使用 for 循環數組)
                pyspark mysql jdbc load An error occurred while calling o23.load No suitable driver(pyspark mysql jdbc load 調用 o23.load 時發生錯誤 沒有合適的驅動程序)
                How to integrate Apache Spark with MySQL for reading database tables as a spark dataframe?(如何將 Apache Spark 與 MySQL 集成以將數據庫表作為 Spark 數據幀讀取?)
                  <tbody id='95ztL'></tbody>
                <i id='95ztL'><tr id='95ztL'><dt id='95ztL'><q id='95ztL'><span id='95ztL'><b id='95ztL'><form id='95ztL'><ins id='95ztL'></ins><ul id='95ztL'></ul><sub id='95ztL'></sub></form><legend id='95ztL'></legend><bdo id='95ztL'><pre id='95ztL'><center id='95ztL'></center></pre></bdo></b><th id='95ztL'></th></span></q></dt></tr></i><div class="qwawimqqmiuu" id='95ztL'><tfoot id='95ztL'></tfoot><dl id='95ztL'><fieldset id='95ztL'></fieldset></dl></div>

                • <bdo id='95ztL'></bdo><ul id='95ztL'></ul>

                  • <legend id='95ztL'><style id='95ztL'><dir id='95ztL'><q id='95ztL'></q></dir></style></legend>
                  • <tfoot id='95ztL'></tfoot>

                        <small id='95ztL'></small><noframes id='95ztL'>

                          主站蜘蛛池模板: 午夜影院在线观看免费 | 99色综合 | 天天操综合网站 | 超碰97人人人人人蜜桃 | 日本久久精品视频 | 福利视频网 | 欧美日韩在线观看一区 | 国产乱码精品一品二品 | 国产精品1区2区3区 国产在线观看一区 | 久久久久久久久久一区二区 | 中文字幕成人在线 | 精品久久成人 | 国产黄色小视频 | 欧美三级在线 | 国产毛片久久久久久久久春天 | av第一页 | aaaa一级毛片 | 99久久久久 | 男人天堂99 | 在线色网 | 久久久婷| 成人深夜福利 | 在线播放国产视频 | 亚洲视频免费 | 亚洲精品一区中文字幕 | 日韩精品av一区二区三区 | 久久久久久综合 | 亚洲高清免费 | 精精久久 | 日日干夜夜操 | 亚洲国产精品久久久 | 亚洲一区 中文字幕 | 中文字幕av一区 | av天天看 | 午夜在线精品偷拍 | v亚洲 | 亚洲一区国产 | 视频一区二区三区中文字幕 | 我我色综合 | 一区在线播放 | 国内自拍第一页 |