A C++ DAL / ORM code generation framework
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 

456 lines
32 KiB

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<title>WORM: WSql::WMysqlDriver Class Reference</title>
<link href="tabs.css" rel="stylesheet" type="text/css"/>
<link href="search/search.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="search/search.js"></script>
<link href="doxygen.css" rel="stylesheet" type="text/css"/>
</head>
<body onload='searchBox.OnSelectItem(0);'>
<!-- Generated by Doxygen 1.7.3 -->
<script type="text/javascript"><!--
var searchBox = new SearchBox("searchBox", "search",false,'Search');
--></script>
<script type="text/javascript">
function hasClass(ele,cls) {
return ele.className.match(new RegExp('(\\s|^)'+cls+'(\\s|$)'));
}
function addClass(ele,cls) {
if (!this.hasClass(ele,cls)) ele.className += " "+cls;
}
function removeClass(ele,cls) {
if (hasClass(ele,cls)) {
var reg = new RegExp('(\\s|^)'+cls+'(\\s|$)');
ele.className=ele.className.replace(reg,' ');
}
}
function toggleVisibility(linkObj) {
var base = linkObj.getAttribute('id');
var summary = document.getElementById(base + '-summary');
var content = document.getElementById(base + '-content');
var trigger = document.getElementById(base + '-trigger');
if ( hasClass(linkObj,'closed') ) {
summary.style.display = 'none';
content.style.display = 'block';
trigger.src = 'open.png';
removeClass(linkObj,'closed');
addClass(linkObj,'opened');
} else if ( hasClass(linkObj,'opened') ) {
summary.style.display = 'block';
content.style.display = 'none';
trigger.src = 'closed.png';
removeClass(linkObj,'opened');
addClass(linkObj,'closed');
}
return false;
}
</script>
<div id="top">
<div id="titlearea">
<table cellspacing="0" cellpadding="0">
<tbody>
<tr style="height: 56px;">
<td id="projectlogo"><img alt="Logo" src="worm_sm.png"></td>
<td style="padding-left: 0.5em;">
<div id="projectname">WORM&#160;<span id="projectnumber">0.2</span></div>
<div id="projectbrief">A C++ DAL/ORM code generation framework</div>
</td>
</tr>
</tbody>
</table>
</div>
<div id="navrow1" class="tabs">
<ul class="tablist">
<li><a href="index.html"><span>Main&#160;Page</span></a></li>
<li><a href="pages.html"><span>Related&#160;Pages</span></a></li>
<li><a href="namespaces.html"><span>Namespaces</span></a></li>
<li class="current"><a href="annotated.html"><span>Classes</span></a></li>
<li><a href="files.html"><span>Files</span></a></li>
<li id="searchli">
<div id="MSearchBox" class="MSearchBoxInactive">
<span class="left">
<img id="MSearchSelect" src="search/mag_sel.png"
onmouseover="return searchBox.OnSearchSelectShow()"
onmouseout="return searchBox.OnSearchSelectHide()"
alt=""/>
<input type="text" id="MSearchField" value="Search" accesskey="S"
onfocus="searchBox.OnSearchFieldFocus(true)"
onblur="searchBox.OnSearchFieldFocus(false)"
onkeyup="searchBox.OnSearchFieldChange(event)"/>
</span><span class="right">
<a id="MSearchClose" href="javascript:searchBox.CloseResultsWindow()"><img id="MSearchCloseImg" border="0" src="search/close.png" alt=""/></a>
</span>
</div>
</li>
</ul>
</div>
<div id="navrow2" class="tabs2">
<ul class="tablist">
<li><a href="annotated.html"><span>Class&#160;List</span></a></li>
<li><a href="classes.html"><span>Class&#160;Index</span></a></li>
<li><a href="hierarchy.html"><span>Class&#160;Hierarchy</span></a></li>
<li><a href="functions.html"><span>Class&#160;Members</span></a></li>
</ul>
</div>
<div id="nav-path" class="navpath">
<ul>
<li class="navelem"><a class="el" href="namespace_w_sql.html">WSql</a> </li>
<li class="navelem"><a class="el" href="class_w_sql_1_1_w_mysql_driver.html">WMysqlDriver</a> </li>
</ul>
</div>
</div>
<div class="header">
<div class="summary">
<a href="#pub-methods">Public Member Functions</a> </div>
<div class="headertitle">
<h1>WSql::WMysqlDriver Class Reference</h1> </div>
</div>
<div class="contents">
<!-- doxytag: class="WSql::WMysqlDriver" --><!-- doxytag: inherits="WSql::WSqlDriver" -->
<p>A driver for MySQL databases.
<a href="#_details">More...</a></p>
<p><code>#include &lt;<a class="el" href="wmysqldriver_8h_source.html">wmysqldriver.h</a>&gt;</code></p>
<div id="dynsection-0" onclick="return toggleVisibility(this)" class="dynheader closed" style="cursor:pointer;">
<img id="dynsection-0-trigger" src="closed.png"/> Inheritance diagram for WSql::WMysqlDriver:</div>
<div id="dynsection-0-summary" class="dynsummary" style="display:block;">
</div>
<div id="dynsection-0-content" class="dyncontent" style="display:none;">
<div class="center">
<img src="class_w_sql_1_1_w_mysql_driver.png" usemap="#WSql::WMysqlDriver_map" alt=""/>
<map id="WSql::WMysqlDriver_map" name="WSql::WMysqlDriver_map">
<area href="class_w_sql_1_1_w_sql_driver.html" alt="WSql::WSqlDriver" shape="rect" coords="0,0,126,24"/>
</map>
</div></div>
<p><a href="class_w_sql_1_1_w_mysql_driver-members.html">List of all members.</a></p>
<table class="memberdecls">
<tr><td colspan="2"><h2><a name="pub-methods"></a>
Public Member Functions</h2></td></tr>
<tr><td class="memItemLeft" align="right" valign="top">&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="class_w_sql_1_1_w_mysql_driver.html#a0ded506c66381a8b23940f475e1cbb16">WMysqlDriver</a> (<a class="el" href="class_w_sql_1_1_w_sql_database.html">WSqlDatabase</a> *db)</td></tr>
<tr><td class="mdescLeft">&#160;</td><td class="mdescRight">Constructs a <a class="el" href="class_w_sql_1_1_w_mysql_driver.html" title="A driver for MySQL databases.">WMysqlDriver</a> with the database <em>db</em>. <a href="#a0ded506c66381a8b23940f475e1cbb16"></a><br/></td></tr>
<tr><td class="memItemLeft" align="right" valign="top">&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="class_w_sql_1_1_w_mysql_driver.html#a06098f6bc312f5afd28ef1b274aeb35e">~WMysqlDriver</a> ()</td></tr>
<tr><td class="memItemLeft" align="right" valign="top">bool&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="class_w_sql_1_1_w_mysql_driver.html#ae53e50ad703fd76da1d34a52b5a844b8">open</a> ()</td></tr>
<tr><td class="mdescLeft">&#160;</td><td class="mdescRight">Opens the connection to the database. <a href="#ae53e50ad703fd76da1d34a52b5a844b8"></a><br/></td></tr>
<tr><td class="memItemLeft" align="right" valign="top">void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="class_w_sql_1_1_w_mysql_driver.html#a347c2c1642d3046292688980dfc5c96b">close</a> ()</td></tr>
<tr><td class="mdescLeft">&#160;</td><td class="mdescRight">Closes the connection and deallocates MYSQL objects. <a href="#a347c2c1642d3046292688980dfc5c96b"></a><br/></td></tr>
<tr><td class="memItemLeft" align="right" valign="top">bool&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="class_w_sql_1_1_w_mysql_driver.html#a16cbd55969cbe2421bcc5ebe2dd0d677">query</a> (std::string sql)</td></tr>
<tr><td class="mdescLeft">&#160;</td><td class="mdescRight">Sends the SQL in <em>sqlstring</em> to the server for execution. <a href="#a16cbd55969cbe2421bcc5ebe2dd0d677"></a><br/></td></tr>
<tr><td class="memItemLeft" align="right" valign="top"><a class="el" href="class_w_sql_1_1_w_sql_result.html">WSqlResult</a> *&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="class_w_sql_1_1_w_mysql_driver.html#a064edf98eaa9453d358818d76627ef6b">result</a> (bool iscached=true)</td></tr>
<tr><td class="mdescLeft">&#160;</td><td class="mdescRight">Return the result from the most recent query. <a href="#a064edf98eaa9453d358818d76627ef6b"></a><br/></td></tr>
<tr><td class="memItemLeft" align="right" valign="top">std::vector&lt; std::string &gt;&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="class_w_sql_1_1_w_mysql_driver.html#aa55eb7fb3c030f4d47aae5fe18435cb6">tableNames</a> ()</td></tr>
<tr><td class="mdescLeft">&#160;</td><td class="mdescRight">Returns a list of the table names in the current database. <a href="#aa55eb7fb3c030f4d47aae5fe18435cb6"></a><br/></td></tr>
<tr><td class="memItemLeft" align="right" valign="top"><a class="el" href="class_w_sql_1_1_w_sql_table.html">WSqlTable</a>&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="class_w_sql_1_1_w_mysql_driver.html#aa770c3b864ee481dc6d83a1d4d49a164">tableMetaData</a> (const std::string &amp;tableName)</td></tr>
<tr><td class="mdescLeft">&#160;</td><td class="mdescRight">Fetch metadata for table <em>tableName</em>. <a href="#aa770c3b864ee481dc6d83a1d4d49a164"></a><br/></td></tr>
<tr><td class="memItemLeft" align="right" valign="top">bool&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="class_w_sql_1_1_w_mysql_driver.html#af101556d203a540b00c53d58d6ed727e">isOpen</a> ()</td></tr>
</table>
<hr/><a name="_details"></a><h2>Detailed Description</h2>
<div class="textblock"><p>A driver for MySQL databases. </p>
<p>This class provides a driver for MySQL databases. It supports: </p>
<ul>
<li>simple queries </li>
<li>(only) cached result sets </li>
<li>metadata retrieval</li>
</ul>
<dl class="todo"><dt><b><a class="el" href="todo.html#_todo000007">Todo:</a></b></dt><dd>uncached results, transactions, prepared statements .. and fix string escaping...</dd></dl>
<p>Definition at line <a class="el" href="wmysqldriver_8h_source.html#l00031">31</a> of file <a class="el" href="wmysqldriver_8h_source.html">wmysqldriver.h</a>.</p>
</div><hr/><h2>Constructor &amp; Destructor Documentation</h2>
<a class="anchor" id="a0ded506c66381a8b23940f475e1cbb16"></a><!-- doxytag: member="WSql::WMysqlDriver::WMysqlDriver" ref="a0ded506c66381a8b23940f475e1cbb16" args="(WSqlDatabase *db)" -->
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">WSql::WMysqlDriver::WMysqlDriver </td>
<td>(</td>
<td class="paramtype"><a class="el" href="class_w_sql_1_1_w_sql_database.html">WSqlDatabase</a> *&#160;</td>
<td class="paramname"><em>db</em></td><td>)</td>
<td></td>
</tr>
</table>
</div>
<div class="memdoc">
<p>Constructs a <a class="el" href="class_w_sql_1_1_w_mysql_driver.html" title="A driver for MySQL databases.">WMysqlDriver</a> with the database <em>db</em>. </p>
<p>This constructor initializes the mysql libraries and prepares for establishing a connection. </p>
<p>Definition at line <a class="el" href="wmysqldriver_8cpp_source.html#l00045">45</a> of file <a class="el" href="wmysqldriver_8cpp_source.html">wmysqldriver.cpp</a>.</p>
</div>
</div>
<a class="anchor" id="a06098f6bc312f5afd28ef1b274aeb35e"></a><!-- doxytag: member="WSql::WMysqlDriver::~WMysqlDriver" ref="a06098f6bc312f5afd28ef1b274aeb35e" args="()" -->
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">WSql::WMysqlDriver::~WMysqlDriver </td>
<td>(</td>
<td class="paramname"></td><td>)</td>
<td></td>
</tr>
</table>
</div>
<div class="memdoc">
<p>Definition at line <a class="el" href="wmysqldriver_8cpp_source.html#l00061">61</a> of file <a class="el" href="wmysqldriver_8cpp_source.html">wmysqldriver.cpp</a>.</p>
</div>
</div>
<hr/><h2>Member Function Documentation</h2>
<a class="anchor" id="a347c2c1642d3046292688980dfc5c96b"></a><!-- doxytag: member="WSql::WMysqlDriver::close" ref="a347c2c1642d3046292688980dfc5c96b" args="()" -->
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">void WSql::WMysqlDriver::close </td>
<td>(</td>
<td class="paramname"></td><td>)</td>
<td><code> [virtual]</code></td>
</tr>
</table>
</div>
<div class="memdoc">
<p>Closes the connection and deallocates MYSQL objects. </p>
<p>This method closes the connection and frees the MYSQL (_mysql) memory. WARNING: Uncached result sets in a <a class="el" href="class_w_sql_1_1_w_sql_result.html" title="The WSqlResult class provides a representation of the result set from a query.">WSqlResult</a> will be INVALID after calling this! It is recommended that one leave this to the destructor - it is called automatically when the <a class="el" href="class_w_sql_1_1_w_mysql_driver.html" title="A driver for MySQL databases.">WMysqlDriver</a> object is destroyed. </p>
<p>Implements <a class="el" href="class_w_sql_1_1_w_sql_driver.html#a17afc1e43627a2a952e76d04420dead0">WSql::WSqlDriver</a>.</p>
<p>Definition at line <a class="el" href="wmysqldriver_8cpp_source.html#l00096">96</a> of file <a class="el" href="wmysqldriver_8cpp_source.html">wmysqldriver.cpp</a>.</p>
</div>
</div>
<a class="anchor" id="af101556d203a540b00c53d58d6ed727e"></a><!-- doxytag: member="WSql::WMysqlDriver::isOpen" ref="af101556d203a540b00c53d58d6ed727e" args="()" -->
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">bool WSql::WMysqlDriver::isOpen </td>
<td>(</td>
<td class="paramname"></td><td>)</td>
<td></td>
</tr>
</table>
</div>
<div class="memdoc">
<p>Definition at line <a class="el" href="wmysqldriver_8cpp_source.html#l00410">410</a> of file <a class="el" href="wmysqldriver_8cpp_source.html">wmysqldriver.cpp</a>.</p>
</div>
</div>
<a class="anchor" id="ae53e50ad703fd76da1d34a52b5a844b8"></a><!-- doxytag: member="WSql::WMysqlDriver::open" ref="ae53e50ad703fd76da1d34a52b5a844b8" args="()" -->
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">bool WSql::WMysqlDriver::open </td>
<td>(</td>
<td class="paramname"></td><td>)</td>
<td><code> [virtual]</code></td>
</tr>
</table>
</div>
<div class="memdoc">
<p>Opens the connection to the database. </p>
<p>This method opens the connection to the database - it must be called before any queries are sent. Note that it may be called more than once - calling this if the connection is still open from a previous call will close and reopen the connection, equivilant to a reset() function. This returns true if the connection was successful otherwise returns false, sets <a class="el" href="class_w_sql_1_1_w_sql_driver.html#aa81bf0a003e897f38574a8ee23348b8d">isValid()</a> and <a class="el" href="class_w_sql_1_1_w_sql_driver.html#aee4657eb1bf5d7d5b8a68dc51da1572f">hasError()</a> to return false and sets an error if possible.</p>
<dl class="note"><dt><b>Note:</b></dt><dd>If this is called after a previous call and the results were not cached any results in the previous <a class="el" href="class_w_sql_1_1_w_sql_result.html" title="The WSqlResult class provides a representation of the result set from a query.">WSqlResult</a> will be INVALID. </dd></dl>
<dl class="return"><dt><b>Returns:</b></dt><dd>bool - true on success </dd></dl>
<p><dl class="todo"><dt><b><a class="el" href="todo.html#_todo000008">Todo:</a></b></dt><dd>set connection options here, esp. utf* and friends </dd></dl>
</p>
<p>Implements <a class="el" href="class_w_sql_1_1_w_sql_driver.html#a2a1f251900715cd1e45aa7a565a57253">WSql::WSqlDriver</a>.</p>
<p>Definition at line <a class="el" href="wmysqldriver_8cpp_source.html#l00119">119</a> of file <a class="el" href="wmysqldriver_8cpp_source.html">wmysqldriver.cpp</a>.</p>
</div>
</div>
<a class="anchor" id="a16cbd55969cbe2421bcc5ebe2dd0d677"></a><!-- doxytag: member="WSql::WMysqlDriver::query" ref="a16cbd55969cbe2421bcc5ebe2dd0d677" args="(std::string sql)" -->
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">bool WSql::WMysqlDriver::query </td>
<td>(</td>
<td class="paramtype">std::string&#160;</td>
<td class="paramname"><em>sqlstring</em></td><td>)</td>
<td><code> [virtual]</code></td>
</tr>
</table>
</div>
<div class="memdoc">
<p>Sends the SQL in <em>sqlstring</em> to the server for execution. </p>
<p>This method sends the SQL given in <em>sqlstring</em> to the server to be executed. If the query was successful it returns true, if not it sets an error and returns false. If the query should return results (eg. a SELECT) they will be available from <a class="el" href="class_w_sql_1_1_w_mysql_driver.html#a064edf98eaa9453d358818d76627ef6b" title="Return the result from the most recent query.">getResult()</a>.</p>
<dl class="return"><dt><b>Returns:</b></dt><dd>bool on success </dd></dl>
<p><dl class="todo"><dt><b><a class="el" href="todo.html#_todo000009">Todo:</a></b></dt><dd>RESOLVE - this also escapes LIKE quotes .. need a way to handle this, ie. a general escape/sanitizer method somewhere .. </dd></dl>
</p>
<p>Implements <a class="el" href="class_w_sql_1_1_w_sql_driver.html#ad15803a5c5d4e8e1d80fec885ed13203">WSql::WSqlDriver</a>.</p>
<p>Definition at line <a class="el" href="wmysqldriver_8cpp_source.html#l00159">159</a> of file <a class="el" href="wmysqldriver_8cpp_source.html">wmysqldriver.cpp</a>.</p>
</div>
</div>
<a class="anchor" id="a064edf98eaa9453d358818d76627ef6b"></a><!-- doxytag: member="WSql::WMysqlDriver::result" ref="a064edf98eaa9453d358818d76627ef6b" args="(bool iscached=true)" -->
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname"><a class="el" href="class_w_sql_1_1_w_sql_result.html">WSqlResult</a> * WSql::WMysqlDriver::result </td>
<td>(</td>
<td class="paramtype">bool&#160;</td>
<td class="paramname"><em>iscached</em> = <code>true</code></td><td>)</td>
<td><code> [virtual]</code></td>
</tr>
</table>
</div>
<div class="memdoc">
<p>Return the result from the most recent query. </p>
<p>This method returns a pointer to a <a class="el" href="class_w_sql_1_1_w_sql_result.html" title="The WSqlResult class provides a representation of the result set from a query.">WSqlResult</a> object containing the most recent result set from a query - it may be empty if no results were returned. You must not delete this pointer yourself - it is owned by the driver.</p>
<p>The parameter <em>iscached</em> may be set to true to indicate a non-cached result set that will be fetched row by row - the default is true and results are cached. (currently uncached results are not yet supported).</p>
<dl class="note"><dt><b>Note:</b></dt><dd>Only use this <em>after</em> a call to <a class="el" href="class_w_sql_1_1_w_mysql_driver.html#a16cbd55969cbe2421bcc5ebe2dd0d677" title="Sends the SQL in sqlstring to the server for execution.">query()</a>! Do not use twice in a row as it will delete the previous result and return a newly created object. Example:</dd></dl>
<div class="fragment"><pre class="fragment"> <a class="code" href="class_w_sql_1_1_w_sql_driver.html#aec208bf350d9750fc15c0c908d7b989a">WSqlDatabase</a> db;
<span class="keywordflow">if</span> (!db.open())
dosomeerror();
<span class="keywordflow">if</span> (!db.query(std::string(<span class="stringliteral">&quot;select foo from bar&quot;</span>)))
dosomeerror();
WSqlResult *<a class="code" href="class_w_sql_1_1_w_mysql_driver.html#a064edf98eaa9453d358818d76627ef6b" title="Return the result from the most recent query.">result</a> = db.getResult();
<span class="comment">//WSqlResult *result2 = db.getResult(); &lt;- wrong </span>
<span class="comment">//...iterate over results ..._then repeat:</span>
<span class="keywordflow">if</span> (!db.query(std::string(<span class="stringliteral">&quot;select baz from bar&quot;</span>)))
dosomeerror();
WSqlResult *result = db.getResult();
..etc.
</pre></div><dl><dt><b>Parameters:</b></dt><dd>
<table class="params">
<tr><td class="paramname">bool</td><td>iscached - if true (the default) fetches entire result set at once. </td></tr>
</table>
</dd>
</dl>
<dl class="return"><dt><b>Returns:</b></dt><dd>WSqlResult* contains the result set </dd></dl>
<p><dl class="todo"><dt><b><a class="el" href="todo.html#_todo000010">Todo:</a></b></dt><dd></dd></dl>
</p>
<p>Reimplemented from <a class="el" href="class_w_sql_1_1_w_sql_driver.html#ae5670416af2dc36911bc29478e5ad0e3">WSql::WSqlDriver</a>.</p>
<p>Definition at line <a class="el" href="wmysqldriver_8cpp_source.html#l00215">215</a> of file <a class="el" href="wmysqldriver_8cpp_source.html">wmysqldriver.cpp</a>.</p>
</div>
</div>
<a class="anchor" id="aa770c3b864ee481dc6d83a1d4d49a164"></a><!-- doxytag: member="WSql::WMysqlDriver::tableMetaData" ref="aa770c3b864ee481dc6d83a1d4d49a164" args="(const std::string &amp;tableName)" -->
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname"><a class="el" href="class_w_sql_1_1_w_sql_table.html">WSqlTable</a> WSql::WMysqlDriver::tableMetaData </td>
<td>(</td>
<td class="paramtype">const std::string &amp;&#160;</td>
<td class="paramname"><em>tableName</em></td><td>)</td>
<td><code> [virtual]</code></td>
</tr>
</table>
</div>
<div class="memdoc">
<p>Fetch metadata for table <em>tableName</em>. </p>
<p>This method returns a <a class="el" href="class_w_sql_1_1_w_sql_table.html" title="WSqlTable is an abstraction for a single table, collection or view in a database.">WSqlTable</a> object populated with WSqlColumns that contain metadata for the columns in the given table <em>tableName</em>. </p>
<dl class="note"><dt><b>Note:</b></dt><dd>It is recommended that this not be used directly but rather from a <a class="el" href="class_w_sql_1_1_w_sql_database.html" title="The WSqlDatabase class represents a single database.">WSqlDatabase</a> object. Note also the warning below - unless you really only need metadata for a single table it is better to initialize all the tables at once with <a class="el" href="class_w_sql_1_1_w_sql_database.html#a9bd1765f14443afbb875981321d4c529" title="Initializes the metadata for all tables in the database.">WSqlDatabase::initMetaData()</a> and avoid the possibility of invalidating a result set.</dd></dl>
<p>Example:</p>
<div class="fragment"><pre class="fragment"> meta_table = db.tableMetaData(*it);
numflds = meta_table.count();
<span class="keywordflow">for</span> (<span class="keywordtype">int</span> i=0; i &lt; numflds; ++i)
{
<a class="code" href="class_w_sql_1_1_w_sql_column.html" title="The WSqlColumn class represents a column in SQL database tables.">WSql::WSqlColumn</a> column = meta_table.column(i);
std::cout &lt;&lt; <span class="stringliteral">&quot;Column &quot;</span> &lt;&lt; i &lt;&lt; <span class="stringliteral">&quot; = &quot;</span> &lt;&lt; column.<a class="code" href="class_w_sql_1_1_w_sql_column.html#a44843e71b5805c2287e00df46185eb71">columnName</a>() &lt;&lt; std::endl;
std::cout &lt;&lt; <span class="stringliteral">&quot; * Data type: &quot;</span> &lt;&lt; <a class="code" href="namespace_w_sql_1_1_w_sql_data_type.html#a35fc6aeb59a9a430f53eb16069742573" title="Covenience function - returns a string for the type.">WSql::WSqlDataType::toString</a>(column.dataType()) &lt;&lt; std::endl;
std::cout &lt;&lt; <span class="stringliteral">&quot; * Max Length: &quot;</span> &lt;&lt; column.<a class="code" href="class_w_sql_1_1_w_sql_column.html#a46eac3f4c5a14bf24bbac67a02787b8b">maxLength</a>() &lt;&lt; std::endl;
std::cout &lt;&lt; <span class="stringliteral">&quot; * Unsigned: &quot;</span> &lt;&lt; (column.<a class="code" href="class_w_sql_1_1_w_sql_column.html#a77fd5a82727a48f5449b62804260d5c3">isUnsigned</a>() ? <span class="stringliteral">&quot;true&quot;</span> : <span class="stringliteral">&quot;false&quot;</span>) &lt;&lt; std::endl;
std::cout &lt;&lt; <span class="stringliteral">&quot; * Can be null: &quot;</span> &lt;&lt; (column.<a class="code" href="class_w_sql_1_1_w_sql_column.html#a8d6cb49198c3215c1b8542ba9ea0f16b">canBeNull</a>() ? <span class="stringliteral">&quot;true&quot;</span> : <span class="stringliteral">&quot;false&quot;</span>) &lt;&lt; std::endl;
std::cout &lt;&lt; <span class="stringliteral">&quot; * Primary key: &quot;</span> &lt;&lt; (column.<a class="code" href="class_w_sql_1_1_w_sql_column.html#a550d941195f306da2e2df25bbd08dee6">isPrimaryKey</a>() ? <span class="stringliteral">&quot;true&quot;</span> : <span class="stringliteral">&quot;false&quot;</span>) &lt;&lt; std::endl;
std::cout &lt;&lt; <span class="stringliteral">&quot; * Autoincrement: &quot;</span> &lt;&lt; (column.<a class="code" href="class_w_sql_1_1_w_sql_column.html#aa1554dddff2918b50300794905f3edbc">isAutoIncremented</a>()?<span class="stringliteral">&quot;true&quot;</span> : <span class="stringliteral">&quot;false&quot;</span>) &lt;&lt; std::endl;
std::cout &lt;&lt; <span class="stringliteral">&quot; * default value: &quot;</span> &lt;&lt; column.<a class="code" href="class_w_sql_1_1_w_sql_column.html#a55feefa5aa00a43a8c8e09a517414047">defaultValue</a>&lt;std::string&gt;() &lt;&lt; std::endl;
}
</pre></div><dl class="warning"><dt><b>Warning:</b></dt><dd>If the table metadata has not been initialized yet this method will invalidate any previous <a class="el" href="class_w_sql_1_1_w_sql_result.html" title="The WSqlResult class provides a representation of the result set from a query.">WSqlResult</a> pointer returned - in this case nesting calls to this method inside of a loop iterating over WSqlResults WILL NOT WORK. Obtain the <a class="el" href="class_w_sql_1_1_w_sql_table.html" title="WSqlTable is an abstraction for a single table, collection or view in a database.">WSqlTable</a> <em>first</em> and <em>then</em> <a class="el" href="class_w_sql_1_1_w_mysql_driver.html#a16cbd55969cbe2421bcc5ebe2dd0d677" title="Sends the SQL in sqlstring to the server for execution.">query()</a> a query and fetch the result set using <a class="el" href="class_w_sql_1_1_w_mysql_driver.html#a064edf98eaa9453d358818d76627ef6b" title="Return the result from the most recent query.">getResult()</a> or use <a class="el" href="class_w_sql_1_1_w_sql_database.html#a9bd1765f14443afbb875981321d4c529" title="Initializes the metadata for all tables in the database.">WSqlDatabase::initMetaData()</a> to initialize the metadata for all tables at once.</dd></dl>
<dl><dt><b>Parameters:</b></dt><dd>
<table class="params">
<tr><td class="paramname">string</td><td>the name of the table to use </td></tr>
</table>
</dd>
</dl>
<dl class="return"><dt><b>Returns:</b></dt><dd><a class="el" href="class_w_sql_1_1_w_sql_table.html" title="WSqlTable is an abstraction for a single table, collection or view in a database.">WSqlTable</a> an object containing metadata </dd></dl>
<dl class="see"><dt><b>See also:</b></dt><dd><a class="el" href="class_w_sql_1_1_w_sql_table.html" title="WSqlTable is an abstraction for a single table, collection or view in a database.">WSqlTable</a> <a class="el" href="class_w_sql_1_1_w_sql_column.html" title="The WSqlColumn class represents a column in SQL database tables.">WSqlColumn</a> </dd></dl>
<p><dl class="todo"><dt><b><a class="el" href="todo.html#_todo000011">Todo:</a></b></dt><dd>change to use strings, defined? and test clm.setColumnName(record.field("Field").data&lt;std::string&gt;()); initColumnType(clm, record.field("Type").data&lt;std::string&gt;()); bool nullable = ! (record.field("Null").data&lt;std::string&gt;().compare("NO") == 0); bool primarykey = (record.field("Key").data&lt;std::string&gt;().compare("PRI") == 0); clm.setDefaultValue( record.field("Default").data&lt;std::string&gt;()); bool isauto = (record.field("Extra").data&lt;std::string&gt;().find("auto_increment") != std::string::npos); </dd></dl>
</p>
<p>Implements <a class="el" href="class_w_sql_1_1_w_sql_driver.html#a2574f1f0d2083f1b0e05f4721f870a74">WSql::WSqlDriver</a>.</p>
<p>Definition at line <a class="el" href="wmysqldriver_8cpp_source.html#l00335">335</a> of file <a class="el" href="wmysqldriver_8cpp_source.html">wmysqldriver.cpp</a>.</p>
</div>
</div>
<a class="anchor" id="aa55eb7fb3c030f4d47aae5fe18435cb6"></a><!-- doxytag: member="WSql::WMysqlDriver::tableNames" ref="aa55eb7fb3c030f4d47aae5fe18435cb6" args="()" -->
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">std::vector&lt; std::string &gt; WSql::WMysqlDriver::tableNames </td>
<td>(</td>
<td class="paramname"></td><td>)</td>
<td><code> [virtual]</code></td>
</tr>
</table>
</div>
<div class="memdoc">
<p>Returns a list of the table names in the current database. </p>
<p>This method will return a vector&lt;string&gt; containing the names of the tables in the current database - the database name must be set first.</p>
<dl class="note"><dt><b>Note:</b></dt><dd>WARNING: This method will invalidate previous WSqlResults returned - nesting calls to this method inside of a loop iterating over WSqlResults will not work. Obtain the list <em>first</em> and <em>aftwards</em> execute a query and fetch the result set using <a class="el" href="class_w_sql_1_1_w_mysql_driver.html#a064edf98eaa9453d358818d76627ef6b" title="Return the result from the most recent query.">getResult()</a>. </dd></dl>
<dl><dt><b>Return values:</b></dt><dd>
<table class="retval">
<tr><td class="paramname">vector&lt;string&gt;</td><td>a list of table names </td></tr>
</table>
</dd>
</dl>
<p>Implements <a class="el" href="class_w_sql_1_1_w_sql_driver.html#adc7f0845587544ad92e3079542e844db">WSql::WSqlDriver</a>.</p>
<p>Definition at line <a class="el" href="wmysqldriver_8cpp_source.html#l00275">275</a> of file <a class="el" href="wmysqldriver_8cpp_source.html">wmysqldriver.cpp</a>.</p>
</div>
</div>
<hr/>The documentation for this class was generated from the following files:<ul>
<li>src/sql/drivers/<a class="el" href="wmysqldriver_8h_source.html">wmysqldriver.h</a></li>
<li>src/sql/drivers/<a class="el" href="wmysqldriver_8cpp_source.html">wmysqldriver.cpp</a></li>
</ul>
</div>
<!--- window showing the filter options -->
<div id="MSearchSelectWindow"
onmouseover="return searchBox.OnSearchSelectShow()"
onmouseout="return searchBox.OnSearchSelectHide()"
onkeydown="return searchBox.OnSearchSelectKey(event)">
<a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(0)"><span class="SelectionMark">&#160;</span>All</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(1)"><span class="SelectionMark">&#160;</span>Classes</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(2)"><span class="SelectionMark">&#160;</span>Namespaces</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(3)"><span class="SelectionMark">&#160;</span>Files</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(4)"><span class="SelectionMark">&#160;</span>Functions</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(5)"><span class="SelectionMark">&#160;</span>Variables</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(6)"><span class="SelectionMark">&#160;</span>Enumerations</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(7)"><span class="SelectionMark">&#160;</span>Enumerator</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(8)"><span class="SelectionMark">&#160;</span>Friends</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(9)"><span class="SelectionMark">&#160;</span>Defines</a></div>
<!-- iframe showing the search results (closed by default) -->
<div id="MSearchResultsWindow">
<iframe src="" frameborder="0"
name="MSearchResults" id="MSearchResults">
</iframe>
</div>
<hr class="footer"/><address class="footer"><small>Generated on Fri Nov 18 2011 21:01:46 for WORM by&#160;
<a href="http://www.doxygen.org/index.html">
<img class="footer" src="doxygen.png" alt="doxygen"/></a> 1.7.3 </small></address>
</body>
</html>