|
|
- <!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: src/sql/wsqldatabase.cpp Source File</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 <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 Page</span></a></li>
- <li><a href="pages.html"><span>Related Pages</span></a></li>
- <li><a href="namespaces.html"><span>Namespaces</span></a></li>
- <li><a href="annotated.html"><span>Classes</span></a></li>
- <li class="current"><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="files.html"><span>File List</span></a></li>
- <li><a href="globals.html"><span>File Members</span></a></li>
- </ul>
- </div>
- <div class="header">
- <div class="headertitle">
- <h1>src/sql/wsqldatabase.cpp</h1> </div>
- </div>
- <div class="contents">
- <a href="wsqldatabase_8cpp.html">Go to the documentation of this file.</a><div class="fragment"><pre class="fragment"><a name="l00001"></a>00001 <span class="comment">/*</span>
- <a name="l00002"></a>00002 <span class="comment"> * WORM - a DAL/ORM code generation framework</span>
- <a name="l00003"></a>00003 <span class="comment"> * Copyright (C) 2011 Erik Winn <erikwinnmail@yahoo.com></span>
- <a name="l00004"></a>00004 <span class="comment"> * </span>
- <a name="l00005"></a>00005 <span class="comment"> * This program is free software: you can redistribute it and/or modify</span>
- <a name="l00006"></a>00006 <span class="comment"> * it under the terms of the GNU General Public License as published by</span>
- <a name="l00007"></a>00007 <span class="comment"> * the Free Software Foundation, either version 3 of the License, or</span>
- <a name="l00008"></a>00008 <span class="comment"> * (at your option) any later version.</span>
- <a name="l00009"></a>00009 <span class="comment"> * </span>
- <a name="l00010"></a>00010 <span class="comment"> * This program is distributed in the hope that it will be useful,</span>
- <a name="l00011"></a>00011 <span class="comment"> * but WITHOUT ANY WARRANTY; without even the implied warranty of</span>
- <a name="l00012"></a>00012 <span class="comment"> * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the</span>
- <a name="l00013"></a>00013 <span class="comment"> * GNU General Public License for more details.</span>
- <a name="l00014"></a>00014 <span class="comment"> * </span>
- <a name="l00015"></a>00015 <span class="comment"> * You should have received a copy of the GNU General Public License</span>
- <a name="l00016"></a>00016 <span class="comment"> * along with this program. If not, see <http://www.gnu.org/licenses/>.</span>
- <a name="l00017"></a>00017 <span class="comment"> */</span>
- <a name="l00018"></a>00018
- <a name="l00019"></a>00019 <span class="preprocessor">#include "<a class="code" href="wsqldatabase_8h.html">wsqldatabase.h</a>"</span>
- <a name="l00020"></a>00020
- <a name="l00021"></a>00021 <span class="preprocessor">#include "<a class="code" href="wsqldriver_8h.html">wsqldriver.h</a>"</span>
- <a name="l00022"></a>00022 <span class="preprocessor">#include "<a class="code" href="wsqlitedriver_8h.html">drivers/wsqlitedriver.h</a>"</span>
- <a name="l00023"></a>00023 <span class="preprocessor">#include "<a class="code" href="wmysqldriver_8h.html">drivers/wmysqldriver.h</a>"</span>
- <a name="l00024"></a>00024
- <a name="l00025"></a>00025 <span class="keyword">namespace </span>WSql {
- <a name="l00026"></a>00026
- <a name="l00093"></a><a class="code" href="class_w_sql_1_1_w_sql_database.html#a093d3810c76b1be2d155c3fd03c0a549">00093</a> <a class="code" href="class_w_sql_1_1_w_sql_database.html#a6ef4f3c3d9c28a9f6aa171261c79b66e" title="Creates an empty, invalid WSqlDatabase object.">WSqlDatabase::WSqlDatabase</a>(<span class="keyword">const</span> <a class="code" href="namespace_w_sql.html#ad184e6e363bbd3ea2b768ac8a013bf3c">WSql::DriverType</a> &type)
- <a name="l00094"></a>00094 {
- <a name="l00095"></a>00095 _driver=0;
- <a name="l00096"></a>00096 _driverType=type;
- <a name="l00097"></a>00097 _isValid=<span class="keyword">false</span>;
- <a name="l00098"></a>00098 init();
- <a name="l00099"></a>00099 }
- <a name="l00100"></a>00100
- <a name="l00104"></a><a class="code" href="class_w_sql_1_1_w_sql_database.html#a6ef4f3c3d9c28a9f6aa171261c79b66e">00104</a> <a class="code" href="class_w_sql_1_1_w_sql_database.html#a6ef4f3c3d9c28a9f6aa171261c79b66e" title="Creates an empty, invalid WSqlDatabase object.">WSqlDatabase::WSqlDatabase</a>()
- <a name="l00105"></a>00105 {
- <a name="l00106"></a>00106 _driver=0;
- <a name="l00107"></a>00107 _isValid=<span class="keyword">false</span>;
- <a name="l00108"></a>00108 }
- <a name="l00109"></a>00109
- <a name="l00118"></a><a class="code" href="class_w_sql_1_1_w_sql_database.html#af69197a0eba8ef5f623971ab69c04b14">00118</a> <a class="code" href="class_w_sql_1_1_w_sql_database.html#a6ef4f3c3d9c28a9f6aa171261c79b66e" title="Creates an empty, invalid WSqlDatabase object.">WSqlDatabase::WSqlDatabase</a>(<span class="keyword">const</span> <a class="code" href="class_w_sql_1_1_w_sql_database.html" title="The WSqlDatabase class represents a single database.">WSqlDatabase</a> &other)
- <a name="l00119"></a>00119 {
- <a name="l00120"></a>00120 _databaseName = other._databaseName;
- <a name="l00121"></a>00121 _userName = other._userName;
- <a name="l00122"></a>00122 _password = other._password;
- <a name="l00123"></a>00123 _hostname = other._hostname;
- <a name="l00124"></a>00124 _port = other._port;
- <a name="l00125"></a>00125 _connectionOptions = other._connectionOptions;
- <a name="l00126"></a>00126 _driverType = other._driverType;
- <a name="l00127"></a>00127 init();
- <a name="l00128"></a>00128 }
- <a name="l00129"></a>00129
- <a name="l00137"></a><a class="code" href="class_w_sql_1_1_w_sql_database.html#a7adeec6b1bf4b1f55fd63cc4a8fe5316">00137</a> <a class="code" href="class_w_sql_1_1_w_sql_database.html#a7adeec6b1bf4b1f55fd63cc4a8fe5316" title="Destroys the object and frees any allocated resources.">WSqlDatabase::~WSqlDatabase</a>()
- <a name="l00138"></a>00138 {
- <a name="l00139"></a>00139 <span class="keywordflow">if</span>(<a class="code" href="class_w_sql_1_1_w_sql_database.html#a4a4d53b3ff1c197b16495087496f8660">isValid</a>()){
- <a name="l00140"></a>00140 <a class="code" href="class_w_sql_1_1_w_sql_database.html#a7d1ff5ea5063fd2a0642584972f9dada">close</a>();
- <a name="l00141"></a>00141 }
- <a name="l00142"></a>00142 <span class="keyword">delete</span> _driver;
- <a name="l00143"></a>00143 }
- <a name="l00144"></a>00144
- <a name="l00152"></a><a class="code" href="class_w_sql_1_1_w_sql_database.html#aff088c6a45f151d872386a930a1ff7a3">00152</a> <a class="code" href="class_w_sql_1_1_w_sql_database.html" title="The WSqlDatabase class represents a single database.">WSqlDatabase</a> &<a class="code" href="class_w_sql_1_1_w_sql_database.html#aff088c6a45f151d872386a930a1ff7a3" title="Copies the values of other to this object.">WSqlDatabase::operator=</a>(<span class="keyword">const</span> <a class="code" href="class_w_sql_1_1_w_sql_database.html" title="The WSqlDatabase class represents a single database.">WSqlDatabase</a> &other)
- <a name="l00153"></a>00153 {
- <a name="l00154"></a>00154 <span class="keywordflow">if</span>(_driver)
- <a name="l00155"></a>00155 <span class="keyword">delete</span> _driver;
- <a name="l00156"></a>00156 _driver=0;
- <a name="l00157"></a>00157
- <a name="l00158"></a>00158 _databaseName = other._databaseName;
- <a name="l00159"></a>00159 _userName = other._userName;
- <a name="l00160"></a>00160 _password = other._password;
- <a name="l00161"></a>00161 _hostname = other._hostname;
- <a name="l00162"></a>00162 _port = other._port;
- <a name="l00163"></a>00163 _connectionOptions = other._connectionOptions;
- <a name="l00164"></a>00164 _driverType = other._driverType;
- <a name="l00165"></a>00165 init();
- <a name="l00166"></a>00166 <span class="keywordflow">return</span> *<span class="keyword">this</span>;
- <a name="l00167"></a>00167 }
- <a name="l00168"></a>00168
- <a name="l00173"></a>00173 <span class="keywordtype">void</span> WSqlDatabase::init()
- <a name="l00174"></a>00174 {
- <a name="l00175"></a>00175 <span class="keywordflow">if</span>(_driver)
- <a name="l00176"></a>00176 <span class="keyword">delete</span> _driver;
- <a name="l00177"></a>00177
- <a name="l00178"></a>00178 _isValid = <a class="code" href="class_w_sql_1_1_w_sql_database.html#a1f865041c95b0962b614c219a918808e">initDriver</a>();
- <a name="l00179"></a>00179 }
- <a name="l00180"></a>00180
- <a name="l00185"></a><a class="code" href="class_w_sql_1_1_w_sql_database.html#a1f865041c95b0962b614c219a918808e">00185</a> <span class="keywordtype">bool</span> <a class="code" href="class_w_sql_1_1_w_sql_database.html#a1f865041c95b0962b614c219a918808e">WSqlDatabase::initDriver</a>()
- <a name="l00186"></a>00186 {
- <a name="l00187"></a>00187 <span class="keywordtype">bool</span> blnToReturn = <span class="keyword">false</span>;
- <a name="l00188"></a>00188 std::string errmsg;
- <a name="l00189"></a>00189
- <a name="l00190"></a>00190 <span class="keywordflow">switch</span>(_driverType)
- <a name="l00191"></a>00191 {
- <a name="l00192"></a>00192 <span class="keywordflow">case</span> <a class="code" href="namespace_w_sql.html#ad184e6e363bbd3ea2b768ac8a013bf3ca7bbb19f6972b9f038408ab359b909a94">WSql::NONE</a>:
- <a name="l00193"></a>00193 errmsg = <span class="stringliteral">"WSqlDatabase: initDriver failed - no driver type set!"</span>;
- <a name="l00194"></a>00194 <span class="keywordflow">break</span>;
- <a name="l00195"></a>00195 <span class="keywordflow">case</span> <a class="code" href="namespace_w_sql.html#ad184e6e363bbd3ea2b768ac8a013bf3ca9139d49f8f6c7eda00cc9470c8307849">WSql::WSQLITE</a> :
- <a name="l00196"></a>00196 _driver = <span class="keyword">new</span> <a class="code" href="class_w_sql_1_1_w_sqlite_driver.html">WSqliteDriver</a>(<span class="keyword">this</span>);
- <a name="l00197"></a>00197 <span class="keywordflow">if</span>(0 == _driver)
- <a name="l00198"></a>00198 errmsg = <span class="stringliteral">"WSqlDatabase: initDriver failed - memory allocation error!"</span>;
- <a name="l00199"></a>00199 <span class="keywordflow">else</span>
- <a name="l00200"></a>00200 blnToReturn = <span class="keyword">true</span>;
- <a name="l00201"></a>00201 <span class="keywordflow">break</span>;
- <a name="l00202"></a>00202 <span class="keywordflow">case</span> <a class="code" href="namespace_w_sql.html#ad184e6e363bbd3ea2b768ac8a013bf3caee837ff3fecf3701ba3c275c3bc38190">WSql::WMYSQL</a> :
- <a name="l00203"></a>00203 _driver = <span class="keyword">new</span> <a class="code" href="class_w_sql_1_1_w_mysql_driver.html" title="A driver for MySQL databases.">WMysqlDriver</a>(<span class="keyword">this</span>);
- <a name="l00204"></a>00204 <span class="keywordflow">if</span>(0 == _driver)
- <a name="l00205"></a>00205 errmsg = <span class="stringliteral">"WSqlDatabase: initDriver failed - memory allocation error!"</span>;
- <a name="l00206"></a>00206 <span class="keywordflow">else</span>
- <a name="l00207"></a>00207 blnToReturn = <span class="keyword">true</span>;
- <a name="l00208"></a>00208 <span class="keywordflow">break</span>;
- <a name="l00209"></a>00209 <span class="keywordflow">case</span> <a class="code" href="namespace_w_sql.html#ad184e6e363bbd3ea2b768ac8a013bf3ca929b79f3124ddffbcf1fae9577b2b5b9">WSql::WMONGO</a> :
- <a name="l00210"></a>00210 <span class="keywordflow">case</span> <a class="code" href="namespace_w_sql.html#ad184e6e363bbd3ea2b768ac8a013bf3ca6a783968e953cd8090f4d5436b1d850a">WSql::WBERKLEYDB</a> :
- <a name="l00211"></a>00211 <span class="keywordflow">case</span> <a class="code" href="namespace_w_sql.html#ad184e6e363bbd3ea2b768ac8a013bf3cae9fd4477804144b8d9f832e0c97da6d7">WSql::WPSQL</a> :
- <a name="l00212"></a>00212 <span class="keywordflow">default</span>:
- <a name="l00213"></a>00213 errmsg = <span class="stringliteral">"WSqlDatabase: initDriver failed - driver unsupported!"</span>;
- <a name="l00214"></a>00214 }
- <a name="l00215"></a>00215 <span class="keywordflow">if</span>(!errmsg.empty())
- <a name="l00216"></a>00216 _errorStack.push_back(<a class="code" href="class_w_sql_1_1_w_sql_error.html" title="The WSqlError class provides SQL database and driver error information.">WSqlError</a>(errmsg,1, <a class="code" href="class_w_sql_1_1_w_sql_error.html#a8bcabd8bf1016ca27304a717ef3d78dbaacc793148eebd48878f5e1b7bb4dfc70">WSqlError::SYSTEM</a>, <a class="code" href="class_w_sql_1_1_w_sql_error.html#a63b2672eb5c68164c4ff43443037f6d9ab01b30be7fcbe01c43222c1b88e7727d">WSqlError::WARNING</a>));
- <a name="l00217"></a>00217 <span class="keywordflow">return</span> blnToReturn;
- <a name="l00218"></a>00218 }
- <a name="l00219"></a>00219
- <a name="l00230"></a><a class="code" href="class_w_sql_1_1_w_sql_database.html#ac40fb73f4b8c5fd26f7cfb959679f1ba">00230</a> <span class="keywordtype">bool</span> <a class="code" href="class_w_sql_1_1_w_sql_database.html#ac40fb73f4b8c5fd26f7cfb959679f1ba" title="Open a connection.">WSqlDatabase::open</a>()
- <a name="l00231"></a>00231 {
- <a name="l00232"></a>00232 <span class="keywordflow">return</span> _driver-><a class="code" href="class_w_sql_1_1_w_sql_driver.html#a2a1f251900715cd1e45aa7a565a57253">open</a>();
- <a name="l00233"></a>00233 }
- <a name="l00234"></a>00234
- <a name="l00245"></a><a class="code" href="class_w_sql_1_1_w_sql_database.html#a8108c44524ad9722c84548f3b7b73d6f">00245</a> <span class="keywordtype">bool</span> <a class="code" href="class_w_sql_1_1_w_sql_database.html#ac40fb73f4b8c5fd26f7cfb959679f1ba" title="Open a connection.">WSqlDatabase::open</a>(<span class="keyword">const</span> std::string& username, <span class="keyword">const</span> std::string& password)
- <a name="l00246"></a>00246 {
- <a name="l00247"></a>00247 <a class="code" href="class_w_sql_1_1_w_sql_database.html#a764e33f918dced0411724a3f4781343a" title="Set the the user name.">setUserName</a>(username);
- <a name="l00248"></a>00248 <a class="code" href="class_w_sql_1_1_w_sql_database.html#a098810c8f81bd4a8f1ea61dc0a3f25ad" title="Set the the password.">setPassword</a>(password);
- <a name="l00249"></a>00249 <span class="keywordflow">return</span> _driver-><a class="code" href="class_w_sql_1_1_w_sql_driver.html#a2a1f251900715cd1e45aa7a565a57253">open</a>();
- <a name="l00250"></a>00250 }
- <a name="l00251"></a>00251
- <a name="l00256"></a><a class="code" href="class_w_sql_1_1_w_sql_database.html#a7d1ff5ea5063fd2a0642584972f9dada">00256</a> <span class="keywordtype">void</span> <a class="code" href="class_w_sql_1_1_w_sql_database.html#a7d1ff5ea5063fd2a0642584972f9dada">WSqlDatabase::close</a>()
- <a name="l00257"></a>00257 {
- <a name="l00258"></a>00258 _driver-><a class="code" href="class_w_sql_1_1_w_sql_driver.html#a17afc1e43627a2a952e76d04420dead0">close</a>();
- <a name="l00259"></a>00259 }
- <a name="l00260"></a>00260
- <a name="l00265"></a><a class="code" href="class_w_sql_1_1_w_sql_database.html#a7c8b8c430fcfaa7d9ef5145c74f7dd48">00265</a> <span class="keywordtype">bool</span> <a class="code" href="class_w_sql_1_1_w_sql_database.html#a7c8b8c430fcfaa7d9ef5145c74f7dd48">WSqlDatabase::isOpen</a>()<span class="keyword"> const</span>
- <a name="l00266"></a>00266 <span class="keyword"></span>{
- <a name="l00267"></a>00267 <span class="keywordflow">return</span> _driver-><a class="code" href="class_w_sql_1_1_w_sql_driver.html#a6c4bf314bfa0d19e476377891a949253">isOpen</a>();
- <a name="l00268"></a>00268 }
- <a name="l00269"></a>00269
- <a name="l00275"></a><a class="code" href="class_w_sql_1_1_w_sql_database.html#a1c943c000ea384846c7d4d77c3513afb">00275</a> <span class="keywordtype">bool</span> <a class="code" href="class_w_sql_1_1_w_sql_database.html#a1c943c000ea384846c7d4d77c3513afb">WSqlDatabase::hasError</a>()<span class="keyword"> const</span>
- <a name="l00276"></a>00276 <span class="keyword"></span>{
- <a name="l00278"></a>00278 <span class="keywordflow">return</span> _driver-><a class="code" href="class_w_sql_1_1_w_sql_driver.html#aee4657eb1bf5d7d5b8a68dc51da1572f">hasError</a>();
- <a name="l00279"></a>00279 }
- <a name="l00280"></a>00280
- <a name="l00281"></a>00281
- <a name="l00292"></a><a class="code" href="class_w_sql_1_1_w_sql_database.html#a9511cd5c63a4375e815ad9dafb5ae7e4">00292</a> <span class="keywordtype">void</span> <a class="code" href="class_w_sql_1_1_w_sql_database.html#a9511cd5c63a4375e815ad9dafb5ae7e4" title="Set the the database name.">WSqlDatabase::setDatabaseName</a>(<span class="keyword">const</span> std::string& name)
- <a name="l00293"></a>00293 {
- <a name="l00294"></a>00294 _databaseName = name;
- <a name="l00295"></a>00295 }
- <a name="l00296"></a>00296
- <a name="l00309"></a><a class="code" href="class_w_sql_1_1_w_sql_database.html#a764e33f918dced0411724a3f4781343a">00309</a> <span class="keywordtype">void</span> <a class="code" href="class_w_sql_1_1_w_sql_database.html#a764e33f918dced0411724a3f4781343a" title="Set the the user name.">WSqlDatabase::setUserName</a>(<span class="keyword">const</span> std::string& name)
- <a name="l00310"></a>00310 {
- <a name="l00311"></a>00311 _userName = name;
- <a name="l00312"></a>00312 }
- <a name="l00313"></a>00313
- <a name="l00326"></a><a class="code" href="class_w_sql_1_1_w_sql_database.html#a098810c8f81bd4a8f1ea61dc0a3f25ad">00326</a> <span class="keywordtype">void</span> <a class="code" href="class_w_sql_1_1_w_sql_database.html#a098810c8f81bd4a8f1ea61dc0a3f25ad" title="Set the the password.">WSqlDatabase::setPassword</a>(<span class="keyword">const</span> std::string& password)
- <a name="l00327"></a>00327 {
- <a name="l00328"></a>00328 _password = <a class="code" href="class_w_sql_1_1_w_sql_database.html#a330a670990fc65f07e48366f05093200">password</a>;
- <a name="l00329"></a>00329 }
- <a name="l00330"></a>00330
- <a name="l00342"></a><a class="code" href="class_w_sql_1_1_w_sql_database.html#ac59ad9647f4c37e1fd11723d8f0d2933">00342</a> <span class="keywordtype">void</span> <a class="code" href="class_w_sql_1_1_w_sql_database.html#ac59ad9647f4c37e1fd11723d8f0d2933" title="Sets the connection&#39;s host name.">WSqlDatabase::setHostName</a>(<span class="keyword">const</span> std::string& hostname)
- <a name="l00343"></a>00343 {
- <a name="l00344"></a>00344 _hostname = hostname;
- <a name="l00345"></a>00345 }
- <a name="l00346"></a>00346
- <a name="l00359"></a><a class="code" href="class_w_sql_1_1_w_sql_database.html#a7b4a7177c16a84bbfd7ae0ca5da0c72c">00359</a> <span class="keywordtype">void</span> <a class="code" href="class_w_sql_1_1_w_sql_database.html#a7b4a7177c16a84bbfd7ae0ca5da0c72c" title="Sets the port number for the connection.">WSqlDatabase::setPort</a>(<span class="keywordtype">int</span> port)
- <a name="l00360"></a>00360 {
- <a name="l00361"></a>00361 _port = <a class="code" href="class_w_sql_1_1_w_sql_database.html#a9d22fff18962918f7301df4c85548ec6" title="Returns the connection&#39;s port number.">port</a>;
- <a name="l00362"></a>00362 }
- <a name="l00363"></a>00363
- <a name="l00368"></a><a class="code" href="class_w_sql_1_1_w_sql_database.html#a83d2116612628889d41c13a9bb67ce0c">00368</a> std::string <a class="code" href="class_w_sql_1_1_w_sql_database.html#a83d2116612628889d41c13a9bb67ce0c">WSqlDatabase::databaseName</a>()<span class="keyword"> const</span>
- <a name="l00369"></a>00369 <span class="keyword"></span>{
- <a name="l00370"></a>00370 <span class="keywordflow">return</span> _databaseName;
- <a name="l00371"></a>00371 }
- <a name="l00372"></a>00372
- <a name="l00378"></a><a class="code" href="class_w_sql_1_1_w_sql_database.html#a8523467f1ed4ba30b800d6cf6224a9b1">00378</a> std::string <a class="code" href="class_w_sql_1_1_w_sql_database.html#a8523467f1ed4ba30b800d6cf6224a9b1">WSqlDatabase::userName</a>()<span class="keyword"> const</span>
- <a name="l00379"></a>00379 <span class="keyword"></span>{
- <a name="l00380"></a>00380 <span class="keywordflow">return</span> _userName;
- <a name="l00381"></a>00381 }
- <a name="l00382"></a>00382
- <a name="l00387"></a><a class="code" href="class_w_sql_1_1_w_sql_database.html#a330a670990fc65f07e48366f05093200">00387</a> std::string <a class="code" href="class_w_sql_1_1_w_sql_database.html#a330a670990fc65f07e48366f05093200">WSqlDatabase::password</a>()<span class="keyword"> const</span>
- <a name="l00388"></a>00388 <span class="keyword"></span>{
- <a name="l00389"></a>00389 <span class="keywordflow">return</span> _password;
- <a name="l00390"></a>00390 }
- <a name="l00391"></a>00391
- <a name="l00397"></a><a class="code" href="class_w_sql_1_1_w_sql_database.html#aaded889a5674813f10c4eff81c90d65d">00397</a> std::string <a class="code" href="class_w_sql_1_1_w_sql_database.html#aaded889a5674813f10c4eff81c90d65d">WSqlDatabase::hostName</a>()<span class="keyword"> const</span>
- <a name="l00398"></a>00398 <span class="keyword"></span>{
- <a name="l00399"></a>00399 <span class="keywordflow">return</span> _hostname;
- <a name="l00400"></a>00400 }
- <a name="l00401"></a>00401
- <a name="l00420"></a><a class="code" href="class_w_sql_1_1_w_sql_database.html#a1fc5a8e3e677b74c98c0e9d0cd39b6dc">00420</a> <a class="code" href="class_w_sql_1_1_w_sql_driver.html" title="The WSqlDriver class is an abstract base class for database drivers.">WSqlDriver</a>* <a class="code" href="class_w_sql_1_1_w_sql_database.html#a1fc5a8e3e677b74c98c0e9d0cd39b6dc" title="Return a pointer to the database driver - expert only.">WSqlDatabase::driver</a>()<span class="keyword"> const</span>
- <a name="l00421"></a>00421 <span class="keyword"></span>{
- <a name="l00422"></a>00422 <span class="keywordflow">return</span> _driver;
- <a name="l00423"></a>00423 }
- <a name="l00424"></a>00424
- <a name="l00430"></a><a class="code" href="class_w_sql_1_1_w_sql_database.html#abc33cf10cd451155204056812e685db8">00430</a> <a class="code" href="class_w_sql_1_1_w_sql_error.html" title="The WSqlError class provides SQL database and driver error information.">WSqlError</a> <a class="code" href="class_w_sql_1_1_w_sql_database.html#abc33cf10cd451155204056812e685db8">WSqlDatabase::error</a>()<span class="keyword"> const</span>
- <a name="l00431"></a>00431 <span class="keyword"></span>{
- <a name="l00432"></a>00432 <span class="keywordflow">return</span> _driver-><a class="code" href="class_w_sql_1_1_w_sql_driver.html#aabd54e13ac3769bfd283cc8e7e937e6f">error</a>();
- <a name="l00433"></a>00433 }
- <a name="l00434"></a>00434
- <a name="l00442"></a>00442 <span class="comment">// WSqlError WSqlDatabase::errors() const</span>
- <a name="l00443"></a>00443 <span class="comment">// {</span>
- <a name="l00444"></a>00444 <span class="comment">// return _driver->getError();</span>
- <a name="l00445"></a>00445 <span class="comment">// }</span>
- <a name="l00446"></a>00446
- <a name="l00447"></a>00447
- <a name="l00467"></a><a class="code" href="class_w_sql_1_1_w_sql_database.html#a86df7db5900c3a2d1483375195c7b025">00467</a> <span class="keyword">const</span> std::vector<std::string>& <a class="code" href="class_w_sql_1_1_w_sql_database.html#a86df7db5900c3a2d1483375195c7b025" title="Returns a vector of the database&#39;s table names.">WSqlDatabase::tableNames</a>(<a class="code" href="namespace_w_sql.html#a2860958b4a0664bf26cd4959a7aaace8">WSql::TableType</a> type)
- <a name="l00468"></a>00468 {
- <a name="l00469"></a>00469 <span class="keywordflow">if</span>(_tableNames.empty())
- <a name="l00470"></a>00470 _tableNames = _driver-><a class="code" href="class_w_sql_1_1_w_sql_driver.html#adc7f0845587544ad92e3079542e844db">tableNames</a>();
- <a name="l00471"></a>00471 <span class="keywordflow">return</span> _tableNames;
- <a name="l00472"></a>00472 }
- <a name="l00473"></a>00473
- <a name="l00509"></a><a class="code" href="class_w_sql_1_1_w_sql_database.html#a2f068c8103068f0b4cab897b824144b9">00509</a> <a class="code" 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="code" href="class_w_sql_1_1_w_sql_database.html#a2f068c8103068f0b4cab897b824144b9" title="Fetch metadata for table tableName.">WSqlDatabase::tableMetaData</a>( <span class="keyword">const</span> std::string& tablename )<span class="keyword"> const</span>
- <a name="l00510"></a>00510 <span class="keyword"></span>{
- <a name="l00511"></a>00511 <span class="keywordflow">if</span>(!<a class="code" href="class_w_sql_1_1_w_sql_database.html#a4a4d53b3ff1c197b16495087496f8660">isValid</a>())
- <a name="l00512"></a>00512 <span class="keywordflow">return</span> <a class="code" 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 name="l00513"></a>00513 <span class="keywordflow">return</span> _driver-><a class="code" href="class_w_sql_1_1_w_sql_driver.html#a2574f1f0d2083f1b0e05f4721f870a74">tableMetaData</a>(tablename);
- <a name="l00514"></a>00514 }
- <a name="l00515"></a>00515
- <a name="l00532"></a><a class="code" href="class_w_sql_1_1_w_sql_database.html#a9bd1765f14443afbb875981321d4c529">00532</a> <span class="keywordtype">void</span> <a class="code" href="class_w_sql_1_1_w_sql_database.html#a9bd1765f14443afbb875981321d4c529" title="Initializes the metadata for all tables in the database.">WSqlDatabase::initMetaData</a>()
- <a name="l00533"></a>00533 {
- <a name="l00534"></a>00534 <span class="comment">//load all tablenames</span>
- <a name="l00535"></a>00535 <a class="code" href="class_w_sql_1_1_w_sql_database.html#a86df7db5900c3a2d1483375195c7b025" title="Returns a vector of the database&#39;s table names.">tableNames</a>();
- <a name="l00536"></a>00536 <span class="comment">//init metadata for all tables</span>
- <a name="l00537"></a>00537 std::vector<std::string>::const_iterator it = _tableNames.begin();
- <a name="l00538"></a>00538 <span class="keywordflow">for</span>(;it != _tableNames.end();++it )
- <a name="l00539"></a>00539 <a class="code" href="class_w_sql_1_1_w_sql_database.html#a2f068c8103068f0b4cab897b824144b9" title="Fetch metadata for table tableName.">tableMetaData</a>(*it);
- <a name="l00540"></a>00540 std::vector<WSqlTable>::const_iterator tbl_it = _driver-><a class="code" href="class_w_sql_1_1_w_sql_driver.html#a4eae8e8af5b50b1bc3a10bf528073724">_tables</a>.begin();
- <a name="l00541"></a>00541 <span class="comment">//add referenced keys</span>
- <a name="l00542"></a>00542 <span class="keywordflow">for</span>(;tbl_it != _driver-><a class="code" href="class_w_sql_1_1_w_sql_driver.html#a4eae8e8af5b50b1bc3a10bf528073724">_tables</a>.end();++tbl_it)
- <a name="l00543"></a>00543 {
- <a name="l00544"></a>00544 std::vector<WSqlForeignKey>::const_iterator fk_it = tbl_it->foreignKeys().begin();
- <a name="l00545"></a>00545 <span class="keywordflow">for</span>(;fk_it != tbl_it->foreignKeys().end();++fk_it)
- <a name="l00546"></a>00546 {
- <a name="l00547"></a>00547 <a class="code" 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> *table = _driver-><a class="code" href="class_w_sql_1_1_w_sql_driver.html#ac8280245a9ab0d63d09c9b7b03c0b3b9" title="Return a reference to the metadata table for tablename in the cache.">getTable</a>( fk_it->referencedTableName());
- <a name="l00548"></a>00548 <span class="keywordflow">if</span>(table)
- <a name="l00549"></a>00549 {
- <a name="l00550"></a>00550 <a class="code" href="class_w_sql_1_1_w_sql_referenced_key.html" title="WSqlReferencedKey provides an abstraction of a referenced column in a database.">WSqlReferencedKey</a> rfk(*fk_it);
- <a name="l00551"></a>00551 table-><a class="code" href="class_w_sql_1_1_w_sql_table.html#a57cf58dd712f9adfa7f98e395447b5ab">addReferencedKey</a>(rfk);
- <a name="l00552"></a>00552 }
- <a name="l00553"></a>00553 }
- <a name="l00554"></a>00554 }
- <a name="l00555"></a>00555 }
- <a name="l00556"></a>00556
- <a name="l00557"></a>00557
- <a name="l00571"></a><a class="code" href="class_w_sql_1_1_w_sql_database.html#a41407aba46af14d6e5d513fbcaac9516">00571</a> <span class="keywordtype">void</span> <a class="code" href="class_w_sql_1_1_w_sql_database.html#a41407aba46af14d6e5d513fbcaac9516" title="Sets the connection options for this database server.">WSqlDatabase::setConnectOptions</a>(<span class="keyword">const</span> std::string &options)
- <a name="l00572"></a>00572 {
- <a name="l00573"></a>00573 _connectionOptions = options;
- <a name="l00574"></a>00574 }
- <a name="l00575"></a>00575
- <a name="l00582"></a><a class="code" href="class_w_sql_1_1_w_sql_database.html#a09f2c6b29cf7eac1b65ee9615aaf9e1c">00582</a> std::string <a class="code" href="class_w_sql_1_1_w_sql_database.html#a09f2c6b29cf7eac1b65ee9615aaf9e1c">WSqlDatabase::connectionOptions</a>()<span class="keyword"> const</span>
- <a name="l00583"></a>00583 <span class="keyword"></span>{
- <a name="l00584"></a>00584 <span class="keywordflow">return</span> _connectionOptions;
- <a name="l00585"></a>00585 }
- <a name="l00586"></a>00586
- <a name="l00590"></a><a class="code" href="class_w_sql_1_1_w_sql_database.html#a4a4d53b3ff1c197b16495087496f8660">00590</a> <span class="keywordtype">bool</span> <a class="code" href="class_w_sql_1_1_w_sql_database.html#a4a4d53b3ff1c197b16495087496f8660">WSqlDatabase::isValid</a>()<span class="keyword"> const</span>
- <a name="l00591"></a>00591 <span class="keyword"></span>{
- <a name="l00592"></a>00592 <span class="keywordflow">return</span> (_isValid && 0 != _driver && _driver-><a class="code" href="class_w_sql_1_1_w_sql_driver.html#aa81bf0a003e897f38574a8ee23348b8d">isValid</a>());
- <a name="l00593"></a>00593 }
- <a name="l00602"></a><a class="code" href="class_w_sql_1_1_w_sql_database.html#a9a368d8a1e0ab21a2ab4b5082acc6a1c">00602</a> <span class="keywordtype">bool</span> <a class="code" href="class_w_sql_1_1_w_sql_database.html#a9a368d8a1e0ab21a2ab4b5082acc6a1c" title="Executes the query in sql returning true on sucess.">WSqlDatabase::query</a>(<span class="keyword">const</span> std::string& sql)
- <a name="l00603"></a>00603 {
- <a name="l00604"></a>00604 <span class="keywordflow">return</span> _driver-><a class="code" href="class_w_sql_1_1_w_sql_driver.html#ad15803a5c5d4e8e1d80fec885ed13203">query</a>(sql);
- <a name="l00605"></a>00605 }
- <a name="l00640"></a><a class="code" href="class_w_sql_1_1_w_sql_database.html#a7f485f7a20f577f5f398c7b5fec07ab7">00640</a> <a class="code" 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> * <a class="code" href="class_w_sql_1_1_w_sql_database.html#a7f485f7a20f577f5f398c7b5fec07ab7" title="Returns a pointer to the result set from the most recent query.">WSqlDatabase::result</a>(<span class="keywordtype">bool</span> iscached)
- <a name="l00641"></a>00641 {
- <a name="l00642"></a>00642 <span class="keywordflow">return</span> _driver-><a class="code" href="class_w_sql_1_1_w_sql_driver.html#ae5670416af2dc36911bc29478e5ad0e3">result</a>(iscached);
- <a name="l00643"></a>00643 }
- <a name="l00644"></a>00644
- <a name="l00645"></a>00645
- <a name="l00646"></a>00646 } <span class="comment">//namespace WSql</span>
- </pre></div></div>
- </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"> </span>All</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(1)"><span class="SelectionMark"> </span>Classes</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(2)"><span class="SelectionMark"> </span>Namespaces</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(3)"><span class="SelectionMark"> </span>Files</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(4)"><span class="SelectionMark"> </span>Functions</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(5)"><span class="SelectionMark"> </span>Variables</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(6)"><span class="SelectionMark"> </span>Enumerations</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(7)"><span class="SelectionMark"> </span>Enumerator</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(8)"><span class="SelectionMark"> </span>Friends</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(9)"><span class="SelectionMark"> </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:45 for WORM by 
- <a href="http://www.doxygen.org/index.html">
- <img class="footer" src="doxygen.png" alt="doxygen"/></a> 1.7.3 </small></address>
- </body>
- </html>
|