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

  1. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  2. <html xmlns="http://www.w3.org/1999/xhtml">
  3. <head>
  4. <meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
  5. <title>WORM: WSql::WMysqlDriver Class Reference</title>
  6. <link href="tabs.css" rel="stylesheet" type="text/css"/>
  7. <link href="search/search.css" rel="stylesheet" type="text/css"/>
  8. <script type="text/javascript" src="search/search.js"></script>
  9. <link href="doxygen.css" rel="stylesheet" type="text/css"/>
  10. </head>
  11. <body onload='searchBox.OnSelectItem(0);'>
  12. <!-- Generated by Doxygen 1.7.3 -->
  13. <script type="text/javascript"><!--
  14. var searchBox = new SearchBox("searchBox", "search",false,'Search');
  15. --></script>
  16. <script type="text/javascript">
  17. function hasClass(ele,cls) {
  18. return ele.className.match(new RegExp('(\\s|^)'+cls+'(\\s|$)'));
  19. }
  20. function addClass(ele,cls) {
  21. if (!this.hasClass(ele,cls)) ele.className += " "+cls;
  22. }
  23. function removeClass(ele,cls) {
  24. if (hasClass(ele,cls)) {
  25. var reg = new RegExp('(\\s|^)'+cls+'(\\s|$)');
  26. ele.className=ele.className.replace(reg,' ');
  27. }
  28. }
  29. function toggleVisibility(linkObj) {
  30. var base = linkObj.getAttribute('id');
  31. var summary = document.getElementById(base + '-summary');
  32. var content = document.getElementById(base + '-content');
  33. var trigger = document.getElementById(base + '-trigger');
  34. if ( hasClass(linkObj,'closed') ) {
  35. summary.style.display = 'none';
  36. content.style.display = 'block';
  37. trigger.src = 'open.png';
  38. removeClass(linkObj,'closed');
  39. addClass(linkObj,'opened');
  40. } else if ( hasClass(linkObj,'opened') ) {
  41. summary.style.display = 'block';
  42. content.style.display = 'none';
  43. trigger.src = 'closed.png';
  44. removeClass(linkObj,'opened');
  45. addClass(linkObj,'closed');
  46. }
  47. return false;
  48. }
  49. </script>
  50. <div id="top">
  51. <div id="titlearea">
  52. <table cellspacing="0" cellpadding="0">
  53. <tbody>
  54. <tr style="height: 56px;">
  55. <td id="projectlogo"><img alt="Logo" src="worm_sm.png"></td>
  56. <td style="padding-left: 0.5em;">
  57. <div id="projectname">WORM&#160;<span id="projectnumber">0.2</span></div>
  58. <div id="projectbrief">A C++ DAL/ORM code generation framework</div>
  59. </td>
  60. </tr>
  61. </tbody>
  62. </table>
  63. </div>
  64. <div id="navrow1" class="tabs">
  65. <ul class="tablist">
  66. <li><a href="index.html"><span>Main&#160;Page</span></a></li>
  67. <li><a href="pages.html"><span>Related&#160;Pages</span></a></li>
  68. <li><a href="namespaces.html"><span>Namespaces</span></a></li>
  69. <li class="current"><a href="annotated.html"><span>Classes</span></a></li>
  70. <li><a href="files.html"><span>Files</span></a></li>
  71. <li id="searchli">
  72. <div id="MSearchBox" class="MSearchBoxInactive">
  73. <span class="left">
  74. <img id="MSearchSelect" src="search/mag_sel.png"
  75. onmouseover="return searchBox.OnSearchSelectShow()"
  76. onmouseout="return searchBox.OnSearchSelectHide()"
  77. alt=""/>
  78. <input type="text" id="MSearchField" value="Search" accesskey="S"
  79. onfocus="searchBox.OnSearchFieldFocus(true)"
  80. onblur="searchBox.OnSearchFieldFocus(false)"
  81. onkeyup="searchBox.OnSearchFieldChange(event)"/>
  82. </span><span class="right">
  83. <a id="MSearchClose" href="javascript:searchBox.CloseResultsWindow()"><img id="MSearchCloseImg" border="0" src="search/close.png" alt=""/></a>
  84. </span>
  85. </div>
  86. </li>
  87. </ul>
  88. </div>
  89. <div id="navrow2" class="tabs2">
  90. <ul class="tablist">
  91. <li><a href="annotated.html"><span>Class&#160;List</span></a></li>
  92. <li><a href="classes.html"><span>Class&#160;Index</span></a></li>
  93. <li><a href="hierarchy.html"><span>Class&#160;Hierarchy</span></a></li>
  94. <li><a href="functions.html"><span>Class&#160;Members</span></a></li>
  95. </ul>
  96. </div>
  97. <div id="nav-path" class="navpath">
  98. <ul>
  99. <li class="navelem"><a class="el" href="namespace_w_sql.html">WSql</a> </li>
  100. <li class="navelem"><a class="el" href="class_w_sql_1_1_w_mysql_driver.html">WMysqlDriver</a> </li>
  101. </ul>
  102. </div>
  103. </div>
  104. <div class="header">
  105. <div class="summary">
  106. <a href="#pub-methods">Public Member Functions</a> </div>
  107. <div class="headertitle">
  108. <h1>WSql::WMysqlDriver Class Reference</h1> </div>
  109. </div>
  110. <div class="contents">
  111. <!-- doxytag: class="WSql::WMysqlDriver" --><!-- doxytag: inherits="WSql::WSqlDriver" -->
  112. <p>A driver for MySQL databases.
  113. <a href="#_details">More...</a></p>
  114. <p><code>#include &lt;<a class="el" href="wmysqldriver_8h_source.html">wmysqldriver.h</a>&gt;</code></p>
  115. <div id="dynsection-0" onclick="return toggleVisibility(this)" class="dynheader closed" style="cursor:pointer;">
  116. <img id="dynsection-0-trigger" src="closed.png"/> Inheritance diagram for WSql::WMysqlDriver:</div>
  117. <div id="dynsection-0-summary" class="dynsummary" style="display:block;">
  118. </div>
  119. <div id="dynsection-0-content" class="dyncontent" style="display:none;">
  120. <div class="center">
  121. <img src="class_w_sql_1_1_w_mysql_driver.png" usemap="#WSql::WMysqlDriver_map" alt=""/>
  122. <map id="WSql::WMysqlDriver_map" name="WSql::WMysqlDriver_map">
  123. <area href="class_w_sql_1_1_w_sql_driver.html" alt="WSql::WSqlDriver" shape="rect" coords="0,0,126,24"/>
  124. </map>
  125. </div></div>
  126. <p><a href="class_w_sql_1_1_w_mysql_driver-members.html">List of all members.</a></p>
  127. <table class="memberdecls">
  128. <tr><td colspan="2"><h2><a name="pub-methods"></a>
  129. Public Member Functions</h2></td></tr>
  130. <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>
  131. <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>
  132. <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>
  133. <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>
  134. <tr><td class="mdescLeft">&#160;</td><td class="mdescRight">Opens the connection to the database. <a href="#ae53e50ad703fd76da1d34a52b5a844b8"></a><br/></td></tr>
  135. <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>
  136. <tr><td class="mdescLeft">&#160;</td><td class="mdescRight">Closes the connection and deallocates MYSQL objects. <a href="#a347c2c1642d3046292688980dfc5c96b"></a><br/></td></tr>
  137. <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>
  138. <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>
  139. <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>
  140. <tr><td class="mdescLeft">&#160;</td><td class="mdescRight">Return the result from the most recent query. <a href="#a064edf98eaa9453d358818d76627ef6b"></a><br/></td></tr>
  141. <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>
  142. <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>
  143. <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>
  144. <tr><td class="mdescLeft">&#160;</td><td class="mdescRight">Fetch metadata for table <em>tableName</em>. <a href="#aa770c3b864ee481dc6d83a1d4d49a164"></a><br/></td></tr>
  145. <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>
  146. </table>
  147. <hr/><a name="_details"></a><h2>Detailed Description</h2>
  148. <div class="textblock"><p>A driver for MySQL databases. </p>
  149. <p>This class provides a driver for MySQL databases. It supports: </p>
  150. <ul>
  151. <li>simple queries </li>
  152. <li>(only) cached result sets </li>
  153. <li>metadata retrieval</li>
  154. </ul>
  155. <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>
  156. <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>
  157. </div><hr/><h2>Constructor &amp; Destructor Documentation</h2>
  158. <a class="anchor" id="a0ded506c66381a8b23940f475e1cbb16"></a><!-- doxytag: member="WSql::WMysqlDriver::WMysqlDriver" ref="a0ded506c66381a8b23940f475e1cbb16" args="(WSqlDatabase *db)" -->
  159. <div class="memitem">
  160. <div class="memproto">
  161. <table class="memname">
  162. <tr>
  163. <td class="memname">WSql::WMysqlDriver::WMysqlDriver </td>
  164. <td>(</td>
  165. <td class="paramtype"><a class="el" href="class_w_sql_1_1_w_sql_database.html">WSqlDatabase</a> *&#160;</td>
  166. <td class="paramname"><em>db</em></td><td>)</td>
  167. <td></td>
  168. </tr>
  169. </table>
  170. </div>
  171. <div class="memdoc">
  172. <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>
  173. <p>This constructor initializes the mysql libraries and prepares for establishing a connection. </p>
  174. <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>
  175. </div>
  176. </div>
  177. <a class="anchor" id="a06098f6bc312f5afd28ef1b274aeb35e"></a><!-- doxytag: member="WSql::WMysqlDriver::~WMysqlDriver" ref="a06098f6bc312f5afd28ef1b274aeb35e" args="()" -->
  178. <div class="memitem">
  179. <div class="memproto">
  180. <table class="memname">
  181. <tr>
  182. <td class="memname">WSql::WMysqlDriver::~WMysqlDriver </td>
  183. <td>(</td>
  184. <td class="paramname"></td><td>)</td>
  185. <td></td>
  186. </tr>
  187. </table>
  188. </div>
  189. <div class="memdoc">
  190. <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>
  191. </div>
  192. </div>
  193. <hr/><h2>Member Function Documentation</h2>
  194. <a class="anchor" id="a347c2c1642d3046292688980dfc5c96b"></a><!-- doxytag: member="WSql::WMysqlDriver::close" ref="a347c2c1642d3046292688980dfc5c96b" args="()" -->
  195. <div class="memitem">
  196. <div class="memproto">
  197. <table class="memname">
  198. <tr>
  199. <td class="memname">void WSql::WMysqlDriver::close </td>
  200. <td>(</td>
  201. <td class="paramname"></td><td>)</td>
  202. <td><code> [virtual]</code></td>
  203. </tr>
  204. </table>
  205. </div>
  206. <div class="memdoc">
  207. <p>Closes the connection and deallocates MYSQL objects. </p>
  208. <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>
  209. <p>Implements <a class="el" href="class_w_sql_1_1_w_sql_driver.html#a17afc1e43627a2a952e76d04420dead0">WSql::WSqlDriver</a>.</p>
  210. <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>
  211. </div>
  212. </div>
  213. <a class="anchor" id="af101556d203a540b00c53d58d6ed727e"></a><!-- doxytag: member="WSql::WMysqlDriver::isOpen" ref="af101556d203a540b00c53d58d6ed727e" args="()" -->
  214. <div class="memitem">
  215. <div class="memproto">
  216. <table class="memname">
  217. <tr>
  218. <td class="memname">bool WSql::WMysqlDriver::isOpen </td>
  219. <td>(</td>
  220. <td class="paramname"></td><td>)</td>
  221. <td></td>
  222. </tr>
  223. </table>
  224. </div>
  225. <div class="memdoc">
  226. <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>
  227. </div>
  228. </div>
  229. <a class="anchor" id="ae53e50ad703fd76da1d34a52b5a844b8"></a><!-- doxytag: member="WSql::WMysqlDriver::open" ref="ae53e50ad703fd76da1d34a52b5a844b8" args="()" -->
  230. <div class="memitem">
  231. <div class="memproto">
  232. <table class="memname">
  233. <tr>
  234. <td class="memname">bool WSql::WMysqlDriver::open </td>
  235. <td>(</td>
  236. <td class="paramname"></td><td>)</td>
  237. <td><code> [virtual]</code></td>
  238. </tr>
  239. </table>
  240. </div>
  241. <div class="memdoc">
  242. <p>Opens the connection to the database. </p>
  243. <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>
  244. <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>
  245. <dl class="return"><dt><b>Returns:</b></dt><dd>bool - true on success </dd></dl>
  246. <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>
  247. </p>
  248. <p>Implements <a class="el" href="class_w_sql_1_1_w_sql_driver.html#a2a1f251900715cd1e45aa7a565a57253">WSql::WSqlDriver</a>.</p>
  249. <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>
  250. </div>
  251. </div>
  252. <a class="anchor" id="a16cbd55969cbe2421bcc5ebe2dd0d677"></a><!-- doxytag: member="WSql::WMysqlDriver::query" ref="a16cbd55969cbe2421bcc5ebe2dd0d677" args="(std::string sql)" -->
  253. <div class="memitem">
  254. <div class="memproto">
  255. <table class="memname">
  256. <tr>
  257. <td class="memname">bool WSql::WMysqlDriver::query </td>
  258. <td>(</td>
  259. <td class="paramtype">std::string&#160;</td>
  260. <td class="paramname"><em>sqlstring</em></td><td>)</td>
  261. <td><code> [virtual]</code></td>
  262. </tr>
  263. </table>
  264. </div>
  265. <div class="memdoc">
  266. <p>Sends the SQL in <em>sqlstring</em> to the server for execution. </p>
  267. <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>
  268. <dl class="return"><dt><b>Returns:</b></dt><dd>bool on success </dd></dl>
  269. <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>
  270. </p>
  271. <p>Implements <a class="el" href="class_w_sql_1_1_w_sql_driver.html#ad15803a5c5d4e8e1d80fec885ed13203">WSql::WSqlDriver</a>.</p>
  272. <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>
  273. </div>
  274. </div>
  275. <a class="anchor" id="a064edf98eaa9453d358818d76627ef6b"></a><!-- doxytag: member="WSql::WMysqlDriver::result" ref="a064edf98eaa9453d358818d76627ef6b" args="(bool iscached=true)" -->
  276. <div class="memitem">
  277. <div class="memproto">
  278. <table class="memname">
  279. <tr>
  280. <td class="memname"><a class="el" href="class_w_sql_1_1_w_sql_result.html">WSqlResult</a> * WSql::WMysqlDriver::result </td>
  281. <td>(</td>
  282. <td class="paramtype">bool&#160;</td>
  283. <td class="paramname"><em>iscached</em> = <code>true</code></td><td>)</td>
  284. <td><code> [virtual]</code></td>
  285. </tr>
  286. </table>
  287. </div>
  288. <div class="memdoc">
  289. <p>Return the result from the most recent query. </p>
  290. <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>
  291. <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>
  292. <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>
  293. <div class="fragment"><pre class="fragment"> <a class="code" href="class_w_sql_1_1_w_sql_driver.html#aec208bf350d9750fc15c0c908d7b989a">WSqlDatabase</a> db;
  294. <span class="keywordflow">if</span> (!db.open())
  295. dosomeerror();
  296. <span class="keywordflow">if</span> (!db.query(std::string(<span class="stringliteral">&quot;select foo from bar&quot;</span>)))
  297. dosomeerror();
  298. 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();
  299. <span class="comment">//WSqlResult *result2 = db.getResult(); &lt;- wrong </span>
  300. <span class="comment">//...iterate over results ..._then repeat:</span>
  301. <span class="keywordflow">if</span> (!db.query(std::string(<span class="stringliteral">&quot;select baz from bar&quot;</span>)))
  302. dosomeerror();
  303. WSqlResult *result = db.getResult();
  304. ..etc.
  305. </pre></div><dl><dt><b>Parameters:</b></dt><dd>
  306. <table class="params">
  307. <tr><td class="paramname">bool</td><td>iscached - if true (the default) fetches entire result set at once. </td></tr>
  308. </table>
  309. </dd>
  310. </dl>
  311. <dl class="return"><dt><b>Returns:</b></dt><dd>WSqlResult* contains the result set </dd></dl>
  312. <p><dl class="todo"><dt><b><a class="el" href="todo.html#_todo000010">Todo:</a></b></dt><dd></dd></dl>
  313. </p>
  314. <p>Reimplemented from <a class="el" href="class_w_sql_1_1_w_sql_driver.html#ae5670416af2dc36911bc29478e5ad0e3">WSql::WSqlDriver</a>.</p>
  315. <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>
  316. </div>
  317. </div>
  318. <a class="anchor" id="aa770c3b864ee481dc6d83a1d4d49a164"></a><!-- doxytag: member="WSql::WMysqlDriver::tableMetaData" ref="aa770c3b864ee481dc6d83a1d4d49a164" args="(const std::string &amp;tableName)" -->
  319. <div class="memitem">
  320. <div class="memproto">
  321. <table class="memname">
  322. <tr>
  323. <td class="memname"><a class="el" href="class_w_sql_1_1_w_sql_table.html">WSqlTable</a> WSql::WMysqlDriver::tableMetaData </td>
  324. <td>(</td>
  325. <td class="paramtype">const std::string &amp;&#160;</td>
  326. <td class="paramname"><em>tableName</em></td><td>)</td>
  327. <td><code> [virtual]</code></td>
  328. </tr>
  329. </table>
  330. </div>
  331. <div class="memdoc">
  332. <p>Fetch metadata for table <em>tableName</em>. </p>
  333. <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>
  334. <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>
  335. <p>Example:</p>
  336. <div class="fragment"><pre class="fragment"> meta_table = db.tableMetaData(*it);
  337. numflds = meta_table.count();
  338. <span class="keywordflow">for</span> (<span class="keywordtype">int</span> i=0; i &lt; numflds; ++i)
  339. {
  340. <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);
  341. 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;
  342. 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;
  343. 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;
  344. 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;
  345. 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;
  346. 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;
  347. 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;
  348. 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;
  349. }
  350. </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>
  351. <dl><dt><b>Parameters:</b></dt><dd>
  352. <table class="params">
  353. <tr><td class="paramname">string</td><td>the name of the table to use </td></tr>
  354. </table>
  355. </dd>
  356. </dl>
  357. <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>
  358. <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>
  359. <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>
  360. </p>
  361. <p>Implements <a class="el" href="class_w_sql_1_1_w_sql_driver.html#a2574f1f0d2083f1b0e05f4721f870a74">WSql::WSqlDriver</a>.</p>
  362. <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>
  363. </div>
  364. </div>
  365. <a class="anchor" id="aa55eb7fb3c030f4d47aae5fe18435cb6"></a><!-- doxytag: member="WSql::WMysqlDriver::tableNames" ref="aa55eb7fb3c030f4d47aae5fe18435cb6" args="()" -->
  366. <div class="memitem">
  367. <div class="memproto">
  368. <table class="memname">
  369. <tr>
  370. <td class="memname">std::vector&lt; std::string &gt; WSql::WMysqlDriver::tableNames </td>
  371. <td>(</td>
  372. <td class="paramname"></td><td>)</td>
  373. <td><code> [virtual]</code></td>
  374. </tr>
  375. </table>
  376. </div>
  377. <div class="memdoc">
  378. <p>Returns a list of the table names in the current database. </p>
  379. <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>
  380. <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>
  381. <dl><dt><b>Return values:</b></dt><dd>
  382. <table class="retval">
  383. <tr><td class="paramname">vector&lt;string&gt;</td><td>a list of table names </td></tr>
  384. </table>
  385. </dd>
  386. </dl>
  387. <p>Implements <a class="el" href="class_w_sql_1_1_w_sql_driver.html#adc7f0845587544ad92e3079542e844db">WSql::WSqlDriver</a>.</p>
  388. <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>
  389. </div>
  390. </div>
  391. <hr/>The documentation for this class was generated from the following files:<ul>
  392. <li>src/sql/drivers/<a class="el" href="wmysqldriver_8h_source.html">wmysqldriver.h</a></li>
  393. <li>src/sql/drivers/<a class="el" href="wmysqldriver_8cpp_source.html">wmysqldriver.cpp</a></li>
  394. </ul>
  395. </div>
  396. <!--- window showing the filter options -->
  397. <div id="MSearchSelectWindow"
  398. onmouseover="return searchBox.OnSearchSelectShow()"
  399. onmouseout="return searchBox.OnSearchSelectHide()"
  400. onkeydown="return searchBox.OnSearchSelectKey(event)">
  401. <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>
  402. <!-- iframe showing the search results (closed by default) -->
  403. <div id="MSearchResultsWindow">
  404. <iframe src="" frameborder="0"
  405. name="MSearchResults" id="MSearchResults">
  406. </iframe>
  407. </div>
  408. <hr class="footer"/><address class="footer"><small>Generated on Fri Nov 18 2011 21:01:46 for WORM by&#160;
  409. <a href="http://www.doxygen.org/index.html">
  410. <img class="footer" src="doxygen.png" alt="doxygen"/></a> 1.7.3 </small></address>
  411. </body>
  412. </html>