Author: wyoung
Date: Mon Nov 10 23:58:21 2008
New Revision: 2403

URL: http://svn.gna.org/viewcvs/mysqlpp?rev=2403&view=rev
Log:
Changed one of the examples and the userman to show a more C++ish way
of iterating through a result set.

Modified:
    trunk/doc/userman/breakages.dbx
    trunk/examples/simple1.cpp

Modified: trunk/doc/userman/breakages.dbx
URL: 
http://svn.gna.org/viewcvs/mysqlpp/trunk/doc/userman/breakages.dbx?rev=2403&r1=2402&r2=2403&view=diff
==============================================================================
--- trunk/doc/userman/breakages.dbx (original)
+++ trunk/doc/userman/breakages.dbx Mon Nov 10 23:58:21 2008
@@ -798,6 +798,16 @@
 mysqlpp::StoreQueryResult::size_type i;
 for (i = 0; i < res.num_rows(); ++i) {
   row = res[i];
+  // Do something with row here
+}</programlisting>
+
+                               <para>...or, in a more C++ish idiom:</para>
+
+        <programlisting>
+mysqlpp::Row row;
+mysqlpp::StoreQueryResult::const_iterator it;
+for (it = res.begin(); it != res.end(); ++it) {
+  row = *it;
   // Do something with row here
 }</programlisting>
       </sect4>

Modified: trunk/examples/simple1.cpp
URL: 
http://svn.gna.org/viewcvs/mysqlpp/trunk/examples/simple1.cpp?rev=2403&r1=2402&r2=2403&view=diff
==============================================================================
--- trunk/examples/simple1.cpp (original)
+++ trunk/examples/simple1.cpp Mon Nov 10 23:58:21 2008
@@ -3,7 +3,7 @@
     table with MySQL++.
 
  Copyright (c) 1998 by Kevin Atkinson, (c) 1999-2001 by MySQL AB, and
- (c) 2004-2007 by Educational Technology Resources, Inc.  Others may
+ (c) 2004-2008 by Educational Technology Resources, Inc.  Others may
  also hold copyrights on code in this file.  See the CREDITS file in
  the top directory of the distribution for details.
 
@@ -52,8 +52,10 @@
                mysqlpp::Query query = conn.query("select item from stock");
                if (mysqlpp::StoreQueryResult res = query.store()) {
                        cout << "We have:" << endl;
-                       for (size_t i = 0; i < res.num_rows(); ++i) {
-                               cout << '\t' << res[i][0] << endl;
+                       mysqlpp::StoreQueryResult::const_iterator it;
+                       for (it = res.begin(); it != res.end(); ++it) {
+                               mysqlpp::Row row = *it;
+                               cout << '\t' << row[0] << endl;
                        }
                }
                else {


_______________________________________________
Mysqlpp-commits mailing list
[email protected]
https://mail.gna.org/listinfo/mysqlpp-commits

Reply via email to