SQT
A C++ ORM framework for SQLite
Loading...
Searching...
No Matches
sqt::Executor< QUERIER > Class Template Reference

#include <sqt/orm/executor/executor.h>

Description

template<QuerierType QUERIER>
class sqt::Executor< QUERIER >

Executes the statement of a querier and retrieves the results.

Template Parameters
QUERIERThe type of the querier to be executed. The available interfaces provided by the executor depend on the querier type.

To create an executor, use the sqt::DataContext::Prepare() method, passing the querier as an argument. The executor shares the same database instance as the data context, so it is safe to use the executor even after the data context is destructed.

If the querier contains placeholders, call the BeginBindings() method to begin a binding process that binds parameters to the placeholders.

The Execute() method is used to execute the statement. For non-select queriers, this method returns nothing, but callers can use the LastChanges() method to retrieve the number of rows affected by the query, or use the LastInsertRowID() method to retrieve the row ID of the last inserted row.

For select queriers, the Execute() method returns a sqt::Result<QUERIER> instance, which can be used to retrieve the results of the query. Refer to sqt::DataContext::MakeSelecter() for the example of retrieving results.

An executor can be reused by calling the Reset() method, which resets the statement's state to allow for re-execution. This is useful when the same statement needs to be executed multiple times with different parameters.

See also
sqt::DataContext<>::Prepare()
sqt::QuerierType
sqt::Result<>

Public Member Functions

 Executor (Statement statement, std::shared_ptr< Database > database) noexcept
 Executor (const Executor &)=delete
Executoroperator= (const Executor &)=delete
 Executor (Executor &&) noexcept=default
Executoroperator= (Executor &&) noexcept=default
auto BeginBindings () noexcept
void Execute ()
auto Execute () noexcept
std::size_t LastChanges () const noexcept
std::int64_t LastInsertRowID () const noexcept
void Reset ()