Wt  3.7.1
Static Public Member Functions | List of all members
Wt::Dbo::query_result_traits< Result > Class Template Reference

Traits class for result types. More...

#include <Wt/Dbo/SqlTraits>

Static Public Member Functions

static void getFields (Session &session, std::vector< std::string > *aliases, std::vector< FieldInfo > &result)
 Obtains the list of fields in this result. More...
 
static Result load (Session &session, SqlStatement &statement, int &column)
 Reads a result from an executed query. More...
 
static void getValues (const Result &result, std::vector< boost::any > &values)
 Returns result values. More...
 
static void setValue (Result &result, int &index, const boost::any &value)
 Sets a result value. More...
 
static Result create ()
 Creates a new result. More...
 
static void add (Session &session, Result &result)
 Adds a new result to the session. More...
 
static void remove (Result &result)
 Removes a result from the session. More...
 
static long long id (const Result &result)
 Returns a unique id for a result. More...
 
static Result findById (Session &session, long long id)
 Find a result by id. More...
 

Detailed Description

template<typename Result>
class Wt::Dbo::query_result_traits< Result >

Traits class for result types.

This traits class may be used to add support for using classes or structs as a result for a Session::query().

The library provides by default support for primitive types, using sql_value_traits, mapped objects held by ptr types, and boost::tuple<> or any combination of these.

See also
sql_value_traits, ptr

Member Function Documentation

◆ add()

template<typename Result >
void Wt::Dbo::query_result_traits< Result >::add ( Session session,
Result &  result 
)
static

Adds a new result to the session.

Adds a (newly created) result to a session.

This method needs to be implemented only if you want to create new results from a QueryModel (which implements Wt's MVC item model).

◆ create()

template<typename Result >
Result Wt::Dbo::query_result_traits< Result >::create ( )
static

Creates a new result.

Creates a new result. This should initialize a result so that its values can be set using setValue() or read using getValues().

The result should not yet be associated with a session.

This method needs to be implemented only if you want to create new results from a QueryModel (which implements Wt's MVC item model).

◆ findById()

template<typename Result >
Result Wt::Dbo::query_result_traits< Result >::findById ( Session session,
long long  id 
)
static

Find a result by id.

This needs to be inverse of id()

◆ getFields()

template<typename Result >
void Wt::Dbo::query_result_traits< Result >::getFields ( Session session,
std::vector< std::string > *  aliases,
std::vector< FieldInfo > &  result 
)
static

Obtains the list of fields in this result.

This is used to build the select clause of an Sql query.

The given aliases 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.

This method is needed when you want to use Result as the result of query.

◆ getValues()

template<typename Result >
void Wt::Dbo::query_result_traits< Result >::getValues ( const Result &  result,
std::vector< boost::any > &  values 
)
static

Returns result values.

This returns the individual field values in the given result.

This method needs to be implemented only if you want to display the result in a QueryModel (which implements Wt's MVC item model).

◆ id()

template<typename Result >
long long Wt::Dbo::query_result_traits< Result >::id ( const Result &  result)
static

Returns a unique id for a result.

This method needs to be implemented to return a unique id for a result which can later be used to find the result.

If not supported, return -1.

See also
findbyId()

◆ load()

template<typename Result >
Result Wt::Dbo::query_result_traits< Result >::load ( Session session,
SqlStatement statement,
int &  column 
)
static

Reads a result from an executed query.

This reads the value from the statement, starting at column column, and advancing the column pointer for as many columns as needed (and according to the number of fields returned by getFields()).

This method is needed when you want to use Result as the result of query.

◆ remove()

template<typename Result >
void Wt::Dbo::query_result_traits< Result >::remove ( Result &  result)
static

Removes a result from the session.

This method needs to be implemented only if you want to remove results from a QueryModel (which implements Wt's MVC item model).

◆ setValue()

template<typename Result >
void Wt::Dbo::query_result_traits< Result >::setValue ( Result &  result,
int &  index,
const boost::any &  value 
)
static

Sets a result value.

Sets the value at index, where index indicates the field whose value needs to be updated.

When index 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.

This method needs to be implemented only if you want to modify the result from a QueryModel (which implements Wt's MVC item model).


Generated on Tue Dec 15 2020 for the C++ Web Toolkit (Wt) by doxygen 1.8.13