Author: tbedford
Date: 2010-09-27 17:32:07 +0200 (Mon, 27 Sep 2010)
New Revision: 22859
Log:
Fixes doc bug #56557.
Modified:
trunk/refman-common/connector-cpp-core.xml
Modified: trunk/refman-common/connector-cpp-core.xml
===================================================================
--- trunk/refman-common/connector-cpp-core.xml 2010-09-27 13:44:55 UTC (rev 22858)
+++ trunk/refman-common/connector-cpp-core.xml 2010-09-27 15:32:07 UTC (rev 22859)
Changed blocks: 2, Lines Added: 21, Lines Deleted: 11; 1777 bytes
@@ -10,7 +10,7 @@
<remark role="dynamic-dependency-list"/>
<para>
- &ccpp; is a MySQL database connector for C++.
+ &ccpp; is a MySQL database connector for C++.
</para>
<para>
@@ -2235,28 +2235,38 @@
cursors.
</para>
-<programlisting>// ...
+<programlisting>
+<![CDATA[
+// ...
sql::Connection *con;
sql::Statement *stmt
sql::ResultSet *res;
// ...
-stmt = con->createStatement();
+stmt = con->createStatement();
// ...
-res = stmt->executeQuery("SELECT id, label FROM test ORDER BY id ASC");
-while (res->next()) {
+res = stmt->executeQuery("SELECT id, label FROM test ORDER BY id ASC");
+while (res->next()) {
// You can use either numeric offsets...
- cout << "id = " <&;t; res->getInt(0);
- // ... or column names for accessing results. »
- The latter is recommended.
- cout << ", label = '" << »
- res->getString("label") << "'" << endl;
+ cout << "id = " << res->getInt(1); // getInt(1) returns the first column
+ // ... or column names for accessing results.
+ // The latter is recommended.
+ cout << ", label = '" << res->getString("label") << "'" << endl;
}
delete res;
delete stmt;
-delete con;</programlisting>
+delete con;
+]]>
+</programlisting>
+ <note>
+ <para>
+ Note in the preceding code snippet that column indexing starts
+ from 1.
+ </para>
+ </note>
+
<para>
Note that you have to free
<classname>sql::Statement</classname>,
| Thread |
|---|
| • svn commit - mysqldoc@docsrva: r22859 - trunk/refman-common | tony.bedford | 27 Sep |