matador::statement< T > Class Template Reference

#include <statement.hpp>

Public Member Functions

 statement (const statement &x)=delete
 
statementoperator= (const statement &x)=delete
 
 statement ()=default
 
 statement (detail::statement_impl *impl, std::shared_ptr< basic_sql_logger > sqllogger)
 
 statement (detail::statement_impl *impl, T prototype, std::shared_ptr< basic_sql_logger > sqllogger)
 
 statement (statement &&x) noexcept
 
statementoperator= (statement &&x) noexcept
 
void clear ()
 
result< T > execute ()
 
void reset ()
 
std::size_t bind (std::size_t index, T *obj)
 
std::size_t bind (std::size_t index, std::string &val, size_t size=0)
 
template<class V >
std::size_t bind (std::size_t index, V &val)
 
std::string str () const
 
void enable_log ()
 
void disable_log ()
 
bool is_log_enabled () const
 

Friends

template<class Type >
class detail::identifier_binder
 

Detailed Description

template<class T = row>
class matador::statement< T >

The statement class represents a prepared sql statement for a concrete object type.

Template Parameters
TThe object type of the statement to work on

Constructor & Destructor Documentation

◆ statement() [1/4]

template<class T = row>
matador::statement< T >::statement ( )
default

Creates an empty statement

◆ statement() [2/4]

template<class T = row>
matador::statement< T >::statement ( detail::statement_impl *  impl,
std::shared_ptr< basic_sql_logger sqllogger 
)
inline

Creates a statement initialized from the given statement implementation object holding the implementation for the selected database

Parameters
implThe statement implementation object
sqlloggerThe logger handler to write sql log messages to

◆ statement() [3/4]

template<class T = row>
matador::statement< T >::statement ( detail::statement_impl *  impl,
prototype,
std::shared_ptr< basic_sql_logger sqllogger 
)
inline

Creates a statement initialized from the given statement implementation object holding the implementation for the selected database

Parameters
implThe statement implementation object
prototypeRow object containing prototype columns
sqlloggerThe logger handler to write sql log messages to

◆ statement() [4/4]

template<class T = row>
matador::statement< T >::statement ( statement< T > &&  x)
inlinenoexcept

Copy move constructor for statement

Parameters
xThe statement to move from

Member Function Documentation

◆ bind() [1/2]

template<class T = row>
std::size_t matador::statement< T >::bind ( std::size_t  index,
std::string &  val,
size_t  size = 0 
)
inline

Bind single value to a specified position index of the prepared statement

Template Parameters
Thetype of the value
Parameters
valThe value to bind
indexThe index where the value is to bind
Returns
The next index to bind

◆ bind() [2/2]

template<class T = row>
std::size_t matador::statement< T >::bind ( std::size_t  index,
T *  obj 
)
inline

Bind an object to the statement starting at the given position index.

Parameters
indexThe index where to start the binding
objThe object to bind
Returns
The next index to bind

◆ clear()

template<class T = row>
void matador::statement< T >::clear ( )
inline

Clear the statement

◆ disable_log()

template<class T = row>
void matador::statement< T >::disable_log ( )
inline

Disable console log of sql statements

◆ enable_log()

template<class T = row>
void matador::statement< T >::enable_log ( )
inline

Enable console log of sql statements

◆ execute()

template<class T = row>
result< T > matador::statement< T >::execute ( )
inline

Executes the prepared statement and returns a result object. If the sql command was a select the result object holds the queried rows.

Returns
The result of the statement

◆ is_log_enabled()

template<class T = row>
bool matador::statement< T >::is_log_enabled ( ) const
inline

Returns true if logging is enabled.

Returns
True if logging is enabled

◆ operator=()

template<class T = row>
statement & matador::statement< T >::operator= ( statement< T > &&  x)
inlinenoexcept

Assignment move constructor for statement

Parameters
xThe statement to move from
Returns
Reference to this

◆ reset()

template<class T = row>
void matador::statement< T >::reset ( )
inline

Resets the statement by unbinding all bindings.

◆ str()

template<class T = row>
std::string matador::statement< T >::str ( ) const
inline

Returns the statement as string where the host values a shown as question marks (?)

Returns
The query string

The documentation for this class was generated from the following file:
  • matador/sql/statement.hpp