Author: wyoung
Date: Thu Jun 28 07:26:53 2007
New Revision: 1631

URL: http://svn.gna.org/viewcvs/mysqlpp?rev=1631&view=rev
Log:
Added for_each() section to userman's tutorial chapter

Modified:
    trunk/doc/userman/Makefile
    trunk/doc/userman/userman.dbx

Modified: trunk/doc/userman/Makefile
URL: 
http://svn.gna.org/viewcvs/mysqlpp/trunk/doc/userman/Makefile?rev=1631&r1=1630&r2=1631&view=diff
==============================================================================
--- trunk/doc/userman/Makefile (original)
+++ trunk/doc/userman/Makefile Thu Jun 28 07:26:53 2007
@@ -18,9 +18,9 @@
 FO_SS=fo.xsl
 HTML_SS=html.xsl
 EX_TXT=cgi_jpeg.txt custom1.txt custom2.txt custom3.txt custom4.txt \
-               custom5.txt custom6.txt fieldinf1.txt load_jpeg.txt \
+               custom5.txt custom6.txt fieldinf1.txt for_each.txt 
load_jpeg.txt \
                resetdb.txt simple1.txt simple2.txt simple3.txt stock.txt \
-               tquery.txt xaction.txt
+               store_if.txt tquery.txt xaction.txt
 
 
 ## ------------------------

Modified: trunk/doc/userman/userman.dbx
URL: 
http://svn.gna.org/viewcvs/mysqlpp/trunk/doc/userman/userman.dbx?rev=1631&r1=1630&r2=1631&view=diff
==============================================================================
--- trunk/doc/userman/userman.dbx (original)
+++ trunk/doc/userman/userman.dbx Thu Jun 28 07:26:53 2007
@@ -840,6 +840,48 @@
         instead look at <filename>examples/usequery.cpp</filename>,
         which does the same thing as <filename>simple3</filename>,
         but with exception-awareness.</para>
+    </sect2>
+
+
+    <sect2>
+        <title>Executing Code for Each Row In a Result Set</title>
+
+        <para>SQL is more than just a database query language. Modern
+        database engines can actually do some calculations on the data
+        on the server side. But, this isn't always the best way to
+        get something done. When you need to mix code and a query,
+        MySQL++'s new <methodname>Query::for_each()</methodname>
+        facility might be just what you need. This is
+        <filename>examples/for_each.cpp</filename>:</para>
+
+        <programlisting><xi:include href="for_each.txt" parse="text"
+        xmlns:xi="http://www.w3.org/2001/XInclude"/></programlisting>
+
+               <para>You only need to read the
+               <function>main()</function> function to get a
+               good idea of what the program does. The key line
+               of code passes an SSQLS examplar and a functor
+               to <methodname>Query::for_each()</methodname>.
+               <methodname>for_each()</methodname> uses the SSQLS
+               instance to build a <computeroutput>select
+               * from TABLE</computeroutput> query,
+               <computeroutput>stock</computeroutput> in this
+               case. It runs that query internally, calling
+               <classname>gather_stock_stats</classname> on each
+               row. This is a pretty contrived example; you could
+               actually do this in SQL, but we're trying to prevent
+               the complexity of the code from getting in the way
+               of the demonstration here.</para>
+
+               <para>If you need a more complex query than the
+               one <methodname>for_each()</methodname> knows
+               how to build, there are two overloads that let
+               you use your own query string. One just takes a
+               functor and uses the query string held within the
+               <classname>Query</classname> object, which you probably
+               built up using <classname>Query</classname>'s stream
+               interface. The other overload just takes the query
+               string directly, along with the functor.</para>
     </sect2>
 
 


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

Reply via email to