db_bridge/mysql_db.cpp
changeset 126 52722ac7693f
parent 65 76514757b0d6
--- a/db_bridge/mysql_db.cpp
+++ b/db_bridge/mysql_db.cpp
@@ -47,7 +47,7 @@
     Abstract_DB::DB_ROW vec;
     Abstract_DB::DB_RESULT rows;
     MYSQL_ROW row;
-    int i = 0;
+    int i = 0, num_fields = 0;
 
     /*
      * send SQL query
@@ -58,14 +58,14 @@
     }
 
     res = mysql_use_result (conn);
+    num_fields = mysql_num_fields (res);
 
     /*
      * push everything into a vector< vector<string> >
      */
     while ((row = mysql_fetch_row (res)) != NULL) {
-        i = 0;
-        while (row[i] != NULL) {
-            vec.push_back (row[i++]);
+	for (i = 0; i < num_fields; i++) {
+            vec.push_back (row[i]);
         }
         rows.push_back (vec);
         vec.clear ();