lintel 0.2.0
Loading...
Searching...
No Matches
Public Member Functions | Static Public Member Functions | List of all members
lintel::db::PreparedStatement Class Reference

#include <PreparedStatement.h>

Public Member Functions

 PreparedStatement (const Connection &connection, const std::string &statement, const std::string &statementName)
 
 ~PreparedStatement ()=default
 
Result execute (const ParameterBuilder &builder)
 
void close ()
 

Static Public Member Functions

static constexpr int32_t initNParams (std::string_view tempStatement)
 
static std::string initStatement (const std::string &tempStatement)
 

Detailed Description

Unified prepared statement wrapping PostgreSQL or SQLite prepared statements.

Constructor & Destructor Documentation

◆ PreparedStatement()

lintel::db::PreparedStatement::PreparedStatement ( const Connection &  connection,
const std::string &  statement,
const std::string &  statementName 
)
explicit

Prepares a statement on the given connection.

Parameters
connectionthe database connection
statementthe SQL statement template
statementNamethe name for the prepared statement

◆ ~PreparedStatement()

lintel::db::PreparedStatement::~PreparedStatement ( )
default

Member Function Documentation

◆ close()

void lintel::db::PreparedStatement::close ( )

Closes the prepared statement and frees associated resources.

◆ execute()

Result lintel::db::PreparedStatement::execute ( const ParameterBuilder &  builder)

Executes the prepared statement with the given parameters.

Parameters
builderthe parameter builder containing parameter values
Returns
the query result

◆ initNParams()

static constexpr int32_t lintel::db::PreparedStatement::initNParams ( std::string_view  tempStatement)
inlinestaticconstexpr

Counts the number of parameter placeholders in a statement template.

Parameters
tempStatementthe statement template with '?' placeholders
Returns
the number of parameters

◆ initStatement()

static std::string lintel::db::PreparedStatement::initStatement ( const std::string &  tempStatement)
static

Converts a statement template with '?' placeholders to the native format.

Parameters
tempStatementthe statement template
Returns
the converted statement string

The documentation for this class was generated from the following file: