<!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>Wt: Wt::Dbo::query_result_traits< Result > Class Template Reference</title> <link href="tabs.css" rel="stylesheet" type="text/css"/> <link href="doxygen.css" rel="stylesheet" type="text/css" /> <link href="search/search.css" rel="stylesheet" type="text/css"/> <script type="text/javascript" src="jquery.js"></script> <script type="text/javascript" src="search/search.js"></script> <script type="text/javascript"> $(document).ready(function() { searchBox.OnSelectItem(0); }); </script> </head> <body> <div id="top"><!-- do not remove this div! --> <div id="titlearea"> <table cellspacing="0" cellpadding="0"> <tbody> <tr style="height: 56px;"> <td style="padding-left: 0.5em;"> <div id="projectname">Wt  <span id="projectnumber">3.2.3</span> </div> </td> </tr> </tbody> </table> </div> <!-- Generated by Doxygen 1.7.5.1 --> <script type="text/javascript"> var searchBox = new SearchBox("searchBox", "search",false,'Search'); </script> <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="modules.html"><span>Modules</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> <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 List</span></a></li> <li><a href="inherits.html"><span>Class Hierarchy</span></a></li> <li><a href="functions.html"><span>Class Members</span></a></li> </ul> </div> <div id="nav-path" class="navpath"> <ul> <li class="navelem"><a class="el" href="namespaceWt.html">Wt</a> </li> <li class="navelem"><a class="el" href="namespaceWt_1_1Dbo.html">Dbo</a> </li> <li class="navelem"><a class="el" href="structWt_1_1Dbo_1_1query__result__traits.html">query_result_traits</a> </li> </ul> </div> </div> <div class="header"> <div class="summary"> <a href="#pub-static-methods">Static Public Member Functions</a> </div> <div class="headertitle"> <div class="title">Wt::Dbo::query_result_traits< Result > Class Template Reference<div class="ingroups"><a class="el" href="group__dbo.html">Database Objects (Wt::Dbo)</a></div></div> </div> </div> <div class="contents"> <!-- doxytag: class="Wt::Dbo::query_result_traits" --> <p>Traits class for result types. <a href="structWt_1_1Dbo_1_1query__result__traits.html#details">More...</a></p> <p><code>#include <Wt/Dbo/SqlTraits></code></p> <p><a href="classWt_1_1Dbo_1_1query__result__traits-members.html">List of all members.</a></p> <table class="memberdecls"> <tr><td colspan="2"><h2><a name="pub-static-methods"></a> Static Public Member Functions</h2></td></tr> <tr><td class="memItemLeft" align="right" valign="top">static void </td><td class="memItemRight" valign="bottom"><a class="el" href="structWt_1_1Dbo_1_1query__result__traits.html#a15021d5b70cb03ee08b39f0c45b02572">getFields</a> (<a class="el" href="classWt_1_1Dbo_1_1Session.html">Session</a> &session, std::vector< std::string > *aliases, std::vector< <a class="el" href="classWt_1_1Dbo_1_1FieldInfo.html">FieldInfo</a> > &result)</td></tr> <tr><td class="mdescLeft"> </td><td class="mdescRight">Obtains the list of fields in this result. <a href="#a15021d5b70cb03ee08b39f0c45b02572"></a><br/></td></tr> <tr><td class="memItemLeft" align="right" valign="top">static Result </td><td class="memItemRight" valign="bottom"><a class="el" href="structWt_1_1Dbo_1_1query__result__traits.html#a24228c4fbd6fd851a44c7aaf3416d0b3">load</a> (<a class="el" href="classWt_1_1Dbo_1_1Session.html">Session</a> &session, <a class="el" href="classWt_1_1Dbo_1_1SqlStatement.html">SqlStatement</a> &statement, int &column)</td></tr> <tr><td class="mdescLeft"> </td><td class="mdescRight">Reads a result from an executed query. <a href="#a24228c4fbd6fd851a44c7aaf3416d0b3"></a><br/></td></tr> <tr><td class="memItemLeft" align="right" valign="top">static void </td><td class="memItemRight" valign="bottom"><a class="el" href="structWt_1_1Dbo_1_1query__result__traits.html#a62ad66f0b19a9afa554cbe6f8fa24ea5">getValues</a> (const Result &result, std::vector< boost::any > &values)</td></tr> <tr><td class="mdescLeft"> </td><td class="mdescRight">Returns result values. <a href="#a62ad66f0b19a9afa554cbe6f8fa24ea5"></a><br/></td></tr> <tr><td class="memItemLeft" align="right" valign="top">static void </td><td class="memItemRight" valign="bottom"><a class="el" href="structWt_1_1Dbo_1_1query__result__traits.html#a31f67f41ac5ac491d59e911a46fe4238">setValue</a> (Result &result, int &index, const boost::any &value)</td></tr> <tr><td class="mdescLeft"> </td><td class="mdescRight">Sets a result value. <a href="#a31f67f41ac5ac491d59e911a46fe4238"></a><br/></td></tr> <tr><td class="memItemLeft" align="right" valign="top">static Result </td><td class="memItemRight" valign="bottom"><a class="el" href="structWt_1_1Dbo_1_1query__result__traits.html#ad5ff66197006a5daef3ce806ad29ddf7">create</a> ()</td></tr> <tr><td class="mdescLeft"> </td><td class="mdescRight">Creates a new result. <a href="#ad5ff66197006a5daef3ce806ad29ddf7"></a><br/></td></tr> <tr><td class="memItemLeft" align="right" valign="top">static void </td><td class="memItemRight" valign="bottom"><a class="el" href="structWt_1_1Dbo_1_1query__result__traits.html#af54fbd95d2319077cacbb718d6f33f1b">add</a> (<a class="el" href="classWt_1_1Dbo_1_1Session.html">Session</a> &session, Result &result)</td></tr> <tr><td class="mdescLeft"> </td><td class="mdescRight">Adds a new result to the session. <a href="#af54fbd95d2319077cacbb718d6f33f1b"></a><br/></td></tr> <tr><td class="memItemLeft" align="right" valign="top">static void </td><td class="memItemRight" valign="bottom"><a class="el" href="structWt_1_1Dbo_1_1query__result__traits.html#ae60de38f7bbffad41f60bd80df2ad8ca">remove</a> (Result &result)</td></tr> <tr><td class="mdescLeft"> </td><td class="mdescRight">Removes a result from the session. <a href="#ae60de38f7bbffad41f60bd80df2ad8ca"></a><br/></td></tr> <tr><td class="memItemLeft" align="right" valign="top">static long long </td><td class="memItemRight" valign="bottom"><a class="el" href="structWt_1_1Dbo_1_1query__result__traits.html#a9bda07d1461175e20b005c58687b0baf">id</a> (const Result &result)</td></tr> <tr><td class="mdescLeft"> </td><td class="mdescRight">Returns a unique id for a result. <a href="#a9bda07d1461175e20b005c58687b0baf"></a><br/></td></tr> <tr><td class="memItemLeft" align="right" valign="top">static Result </td><td class="memItemRight" valign="bottom"><a class="el" href="structWt_1_1Dbo_1_1query__result__traits.html#a14af7eff41790d5f0328d09a5fb57748">findById</a> (<a class="el" href="classWt_1_1Dbo_1_1Session.html">Session</a> &session, long long id)</td></tr> <tr><td class="mdescLeft"> </td><td class="mdescRight">Find a result by id. <a href="#a14af7eff41790d5f0328d09a5fb57748"></a><br/></td></tr> </table> <hr/><a name="details" id="details"></a><h2>Detailed Description</h2> <div class="textblock"><h3>template<typename Result><br/> class Wt::Dbo::query_result_traits< Result ></h3> <p>Traits class for result types. </p> <p>This traits class may be used to add support for using classes or structs as a result for a <a class="el" href="classWt_1_1Dbo_1_1Session.html#a8cad70bef9cffd6613107d5cd3aeb16a" title="Creates a query.">Session::query()</a>.</p> <p>The library provides by default support for primitive types, using <a class="el" href="structWt_1_1Dbo_1_1sql__value__traits.html" title="Traits class for value types.">sql_value_traits</a>, mapped objects held by ptr types, and boost::tuple<> of any combination of these.</p> <dl class="see"><dt><b>See also:</b></dt><dd><a class="el" href="structWt_1_1Dbo_1_1sql__value__traits.html" title="Traits class for value types.">sql_value_traits</a>, <a class="el" href="classWt_1_1Dbo_1_1ptr.html" title="A smart pointer for a database object.">ptr</a> </dd></dl> </div><hr/><h2>Member Function Documentation</h2> <a class="anchor" id="af54fbd95d2319077cacbb718d6f33f1b"></a><!-- doxytag: member="Wt::Dbo::query_result_traits::add" ref="af54fbd95d2319077cacbb718d6f33f1b" args="(Session &session, Result &result)" --> <div class="memitem"> <div class="memproto"> <div class="memtemplate"> template<typename Result > </div> <table class="memname"> <tr> <td class="memname">void <a class="el" href="structWt_1_1Dbo_1_1query__result__traits.html">Wt::Dbo::query_result_traits</a>< Result >::add </td> <td>(</td> <td class="paramtype"><a class="el" href="classWt_1_1Dbo_1_1Session.html">Session</a> & </td> <td class="paramname"><em>session</em>, </td> </tr> <tr> <td class="paramkey"></td> <td></td> <td class="paramtype">Result & </td> <td class="paramname"><em>result</em> </td> </tr> <tr> <td></td> <td>)</td> <td></td><td><code> [static]</code></td> </tr> </table> </div> <div class="memdoc"> <p>Adds a new result to the session. </p> <p>Adds a (newly created) result to a session.</p> <p>This method needs to be implemented only if you want to create new results from a <a class="el" href="classWt_1_1Dbo_1_1QueryModel.html" title="A Wt MVC Model to view/edit query results.">QueryModel</a> (which implements Wt's MVC item model). </p> </div> </div> <a class="anchor" id="ad5ff66197006a5daef3ce806ad29ddf7"></a><!-- doxytag: member="Wt::Dbo::query_result_traits::create" ref="ad5ff66197006a5daef3ce806ad29ddf7" args="()" --> <div class="memitem"> <div class="memproto"> <div class="memtemplate"> template<typename Result > </div> <table class="memname"> <tr> <td class="memname">Result <a class="el" href="structWt_1_1Dbo_1_1query__result__traits.html">Wt::Dbo::query_result_traits</a>< Result >::create </td> <td>(</td> <td class="paramname"></td><td>)</td> <td><code> [static]</code></td> </tr> </table> </div> <div class="memdoc"> <p>Creates a new result. </p> <p>Creates a new result. This should initialize a result so that its values can be set using <a class="el" href="structWt_1_1Dbo_1_1query__result__traits.html#a31f67f41ac5ac491d59e911a46fe4238" title="Sets a result value.">setValue()</a> or read using <a class="el" href="structWt_1_1Dbo_1_1query__result__traits.html#a62ad66f0b19a9afa554cbe6f8fa24ea5" title="Returns result values.">getValues()</a>.</p> <p>The result should not yet be associated with a session.</p> <p>This method needs to be implemented only if you want to create new results from a <a class="el" href="classWt_1_1Dbo_1_1QueryModel.html" title="A Wt MVC Model to view/edit query results.">QueryModel</a> (which implements Wt's MVC item model). </p> </div> </div> <a class="anchor" id="a14af7eff41790d5f0328d09a5fb57748"></a><!-- doxytag: member="Wt::Dbo::query_result_traits::findById" ref="a14af7eff41790d5f0328d09a5fb57748" args="(Session &session, long long id)" --> <div class="memitem"> <div class="memproto"> <div class="memtemplate"> template<typename Result > </div> <table class="memname"> <tr> <td class="memname">static Result <a class="el" href="structWt_1_1Dbo_1_1query__result__traits.html">Wt::Dbo::query_result_traits</a>< Result >::findById </td> <td>(</td> <td class="paramtype"><a class="el" href="classWt_1_1Dbo_1_1Session.html">Session</a> & </td> <td class="paramname"><em>session</em>, </td> </tr> <tr> <td class="paramkey"></td> <td></td> <td class="paramtype">long long </td> <td class="paramname"><em>id</em> </td> </tr> <tr> <td></td> <td>)</td> <td></td><td><code> [static]</code></td> </tr> </table> </div> <div class="memdoc"> <p>Find a result by id. </p> <p>This needs to be inverse of <a class="el" href="structWt_1_1Dbo_1_1query__result__traits.html#a9bda07d1461175e20b005c58687b0baf" title="Returns a unique id for a result.">id()</a> </p> </div> </div> <a class="anchor" id="a15021d5b70cb03ee08b39f0c45b02572"></a><!-- doxytag: member="Wt::Dbo::query_result_traits::getFields" ref="a15021d5b70cb03ee08b39f0c45b02572" args="(Session &session, std::vector< std::string > *aliases, std::vector< FieldInfo > &result)" --> <div class="memitem"> <div class="memproto"> <div class="memtemplate"> template<typename Result > </div> <table class="memname"> <tr> <td class="memname">void <a class="el" href="structWt_1_1Dbo_1_1query__result__traits.html">Wt::Dbo::query_result_traits</a>< Result >::getFields </td> <td>(</td> <td class="paramtype"><a class="el" href="classWt_1_1Dbo_1_1Session.html">Session</a> & </td> <td class="paramname"><em>session</em>, </td> </tr> <tr> <td class="paramkey"></td> <td></td> <td class="paramtype">std::vector< std::string > * </td> <td class="paramname"><em>aliases</em>, </td> </tr> <tr> <td class="paramkey"></td> <td></td> <td class="paramtype">std::vector< <a class="el" href="classWt_1_1Dbo_1_1FieldInfo.html">FieldInfo</a> > & </td> <td class="paramname"><em>result</em> </td> </tr> <tr> <td></td> <td>)</td> <td></td><td><code> [static]</code></td> </tr> </table> </div> <div class="memdoc"> <p>Obtains the list of fields in this result. </p> <p>This is used to build the <em>select</em> clause of an Sql query.</p> <p>The given <code>aliases</code> may be used to qualify fields that correspond to entire tables (popping values from the front of this vector). An exception is thrown if not enough aliases were provided.</p> <p>This method is needed when you want to use Result as the result of query. </p> </div> </div> <a class="anchor" id="a62ad66f0b19a9afa554cbe6f8fa24ea5"></a><!-- doxytag: member="Wt::Dbo::query_result_traits::getValues" ref="a62ad66f0b19a9afa554cbe6f8fa24ea5" args="(const Result &result, std::vector< boost::any > &values)" --> <div class="memitem"> <div class="memproto"> <div class="memtemplate"> template<typename Result > </div> <table class="memname"> <tr> <td class="memname">void <a class="el" href="structWt_1_1Dbo_1_1query__result__traits.html">Wt::Dbo::query_result_traits</a>< Result >::getValues </td> <td>(</td> <td class="paramtype">const Result & </td> <td class="paramname"><em>result</em>, </td> </tr> <tr> <td class="paramkey"></td> <td></td> <td class="paramtype">std::vector< boost::any > & </td> <td class="paramname"><em>values</em> </td> </tr> <tr> <td></td> <td>)</td> <td></td><td><code> [static]</code></td> </tr> </table> </div> <div class="memdoc"> <p>Returns result values. </p> <p>This returns the individual field values in the given <code>result</code>.</p> <p>This method needs to be implemented only if you want to display the result in a <a class="el" href="classWt_1_1Dbo_1_1QueryModel.html" title="A Wt MVC Model to view/edit query results.">QueryModel</a> (which implements Wt's MVC item model). </p> </div> </div> <a class="anchor" id="a9bda07d1461175e20b005c58687b0baf"></a><!-- doxytag: member="Wt::Dbo::query_result_traits::id" ref="a9bda07d1461175e20b005c58687b0baf" args="(const Result &result)" --> <div class="memitem"> <div class="memproto"> <div class="memtemplate"> template<typename Result > </div> <table class="memname"> <tr> <td class="memname">static long long <a class="el" href="structWt_1_1Dbo_1_1query__result__traits.html">Wt::Dbo::query_result_traits</a>< Result >::id </td> <td>(</td> <td class="paramtype">const Result & </td> <td class="paramname"><em>result</em></td><td>)</td> <td><code> [static]</code></td> </tr> </table> </div> <div class="memdoc"> <p>Returns a unique id for a result. </p> <p>This method needs to be implemented to return a unique id for a result which can later be used to find the result.</p> <p>If not supported, return -1.</p> <dl class="see"><dt><b>See also:</b></dt><dd>findbyId() </dd></dl> </div> </div> <a class="anchor" id="a24228c4fbd6fd851a44c7aaf3416d0b3"></a><!-- doxytag: member="Wt::Dbo::query_result_traits::load" ref="a24228c4fbd6fd851a44c7aaf3416d0b3" args="(Session &session, SqlStatement &statement, int &column)" --> <div class="memitem"> <div class="memproto"> <div class="memtemplate"> template<typename Result > </div> <table class="memname"> <tr> <td class="memname">Result <a class="el" href="structWt_1_1Dbo_1_1query__result__traits.html">Wt::Dbo::query_result_traits</a>< Result >::load </td> <td>(</td> <td class="paramtype"><a class="el" href="classWt_1_1Dbo_1_1Session.html">Session</a> & </td> <td class="paramname"><em>session</em>, </td> </tr> <tr> <td class="paramkey"></td> <td></td> <td class="paramtype"><a class="el" href="classWt_1_1Dbo_1_1SqlStatement.html">SqlStatement</a> & </td> <td class="paramname"><em>statement</em>, </td> </tr> <tr> <td class="paramkey"></td> <td></td> <td class="paramtype">int & </td> <td class="paramname"><em>column</em> </td> </tr> <tr> <td></td> <td>)</td> <td></td><td><code> [static]</code></td> </tr> </table> </div> <div class="memdoc"> <p>Reads a result from an executed query. </p> <p>This reads the value from the <code>statement</code>, starting at column <code>column</code>, and advancing the column pointer for as many columns as needed (and according to the number of fields returned by <a class="el" href="structWt_1_1Dbo_1_1query__result__traits.html#a15021d5b70cb03ee08b39f0c45b02572" title="Obtains the list of fields in this result.">getFields()</a>).</p> <p>This method is needed when you want to use Result as the result of query. </p> </div> </div> <a class="anchor" id="ae60de38f7bbffad41f60bd80df2ad8ca"></a><!-- doxytag: member="Wt::Dbo::query_result_traits::remove" ref="ae60de38f7bbffad41f60bd80df2ad8ca" args="(Result &result)" --> <div class="memitem"> <div class="memproto"> <div class="memtemplate"> template<typename Result > </div> <table class="memname"> <tr> <td class="memname">void <a class="el" href="structWt_1_1Dbo_1_1query__result__traits.html">Wt::Dbo::query_result_traits</a>< Result >::remove </td> <td>(</td> <td class="paramtype">Result & </td> <td class="paramname"><em>result</em></td><td>)</td> <td><code> [static]</code></td> </tr> </table> </div> <div class="memdoc"> <p>Removes a result from the session. </p> <p>This method needs to be implemented only if you want to remove results from a <a class="el" href="classWt_1_1Dbo_1_1QueryModel.html" title="A Wt MVC Model to view/edit query results.">QueryModel</a> (which implements Wt's MVC item model). </p> </div> </div> <a class="anchor" id="a31f67f41ac5ac491d59e911a46fe4238"></a><!-- doxytag: member="Wt::Dbo::query_result_traits::setValue" ref="a31f67f41ac5ac491d59e911a46fe4238" args="(Result &result, int &index, const boost::any &value)" --> <div class="memitem"> <div class="memproto"> <div class="memtemplate"> template<typename Result > </div> <table class="memname"> <tr> <td class="memname">void <a class="el" href="structWt_1_1Dbo_1_1query__result__traits.html">Wt::Dbo::query_result_traits</a>< Result >::setValue </td> <td>(</td> <td class="paramtype">Result & </td> <td class="paramname"><em>result</em>, </td> </tr> <tr> <td class="paramkey"></td> <td></td> <td class="paramtype">int & </td> <td class="paramname"><em>index</em>, </td> </tr> <tr> <td class="paramkey"></td> <td></td> <td class="paramtype">const boost::any & </td> <td class="paramname"><em>value</em> </td> </tr> <tr> <td></td> <td>)</td> <td></td><td><code> [static]</code></td> </tr> </table> </div> <div class="memdoc"> <p>Sets a result value. </p> <p>Sets the value at <code>index</code>, where index indicates the field whose value needs to be updated.</p> <p>When <code>index</code> is out-of-bounds, it should be decremented with as many fields as there are in this result type. Otherwise, index should be set to -1 after the value has been set.</p> <p>This method needs to be implemented only if you want to modify the result from a <a class="el" href="classWt_1_1Dbo_1_1QueryModel.html" title="A Wt MVC Model to view/edit query results.">QueryModel</a> (which implements Wt's MVC item model). </p> </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>Typedefs</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(7)"><span class="SelectionMark"> </span>Enumerations</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(8)"><span class="SelectionMark"> </span>Enumerator</a></div> <!-- iframe showing the search results (closed by default) --> <div id="MSearchResultsWindow"> <iframe src="javascript:void(0)" frameborder="0" name="MSearchResults" id="MSearchResults"> </iframe> </div> <hr size="1"><address style="text-align: right; margin: 3px"><small> Generated on Thu Nov 1 2012 for <a href="http://www.webtoolkit.eu/wt">the C++ Web Toolkit (Wt)</a> by <a href="http://www.doxygen.org/index.html"><img src="doxygen.png" alt="doxygen" border="0" style="vertical-align: middle; display: inline-block; height: 2em"></a> 1.7.5.1</small></address> </body> </html>