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. | |
static Result | load (Session &session, SqlStatement &statement, int &column) |
Reads a result from an executed query. | |
static void | getValues (const Result &result, std::vector< boost::any > &values) |
Returns result values. | |
static void | setValue (Result &result, int &index, const boost::any &value) |
Sets a result value. | |
static Result | create () |
Creates a new result. | |
static void | add (Session &session, Result &result) |
Adds a new result to the session. | |
static void | remove (Result &result) |
Removes a result from the session. |
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<> of any combination of these.
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).
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).
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.
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).
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.
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).
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).