AnCH Framework 0.1
Another C++ Hack Framework
 
Loading...
Searching...
No Matches
anch::sql::PreparedStatement Class Referenceabstract

SQL prepared statement. More...

#include <preparedStatement.hpp>

+ Inheritance diagram for anch::sql::PreparedStatement:
+ Collaboration diagram for anch::sql::PreparedStatement:

Public Member Functions

 PreparedStatement () noexcept
 
virtual ~PreparedStatement () noexcept
 
virtual ResultSetexecuteQuery ()=0
 
virtual uint64_t executeUpdate ()=0
 
void set (std::size_t idx, int16_t value)
 
void set (std::size_t idx, uint16_t value)
 
void set (std::size_t idx, int32_t value)
 
void set (std::size_t idx, uint32_t value)
 
void set (std::size_t idx, int64_t value)
 
void set (std::size_t idx, uint64_t value)
 
void set (std::size_t idx, const std::string &value)
 
void set (std::size_t idx, const char *const value)
 
virtual void set (std::size_t idx, const anch::sql::Date &value)
 
virtual void set (std::size_t idx, const anch::sql::Time &value)
 
virtual void set (std::size_t idx, const anch::sql::Timestamp &value)
 

Protected Member Functions

std::set< std::size_t > getPlaceholders (const std::string &query) const
 
void checkIndex (std::size_t index) const
 

Protected Attributes

std::map< std::size_t, std::string > _values
 
std::size_t _nbPlaceholders
 

Detailed Description

SQL prepared statement.

Virtual class for SQL prepared statement management.

Author
Vincent Lachenal
Since
0.1

Constructor & Destructor Documentation

◆ PreparedStatement()

anch::sql::PreparedStatement::PreparedStatement ( )
noexcept

PreparedStatement constructor

◆ ~PreparedStatement()

virtual anch::sql::PreparedStatement::~PreparedStatement ( )
virtualnoexcept

PreparedStatement destructor

+ Here is the call graph for this function:

Member Function Documentation

◆ checkIndex()

void anch::sql::PreparedStatement::checkIndex ( std::size_t index) const
inlineprotected

Check index value

Parameters
indexthe index to check
Exceptions
SqlExceptionthe index is upper than number of wildcards
+ Here is the call graph for this function:

◆ executeQuery()

virtual ResultSet * anch::sql::PreparedStatement::executeQuery ( )
pure virtual

Execute prepared statement for SELECT statement

Returns
the result set
Exceptions
SqlExceptionany error

Implemented in anch::sql::MySQLPreparedStatement, anch::sql::PostgreSQLPreparedStatement, and anch::sql::SQLite3PreparedStatement.

+ Here is the call graph for this function:

◆ executeUpdate()

virtual uint64_t anch::sql::PreparedStatement::executeUpdate ( )
pure virtual

Execute prepared statement for update database (INSERT, UPDATE, DELETE)

Returns
the number of affected rows
Exceptions
SqlExceptionany error

Implemented in anch::sql::MySQLPreparedStatement, anch::sql::PostgreSQLPreparedStatement, and anch::sql::SQLite3PreparedStatement.

+ Here is the call graph for this function:

◆ getPlaceholders()

std::set< std::size_t > anch::sql::PreparedStatement::getPlaceholders ( const std::string & query) const
protected

Retrieve placeholders positions ('?') in SQL query

Parameters
querythe SQL query
Returns
the placeholders' position
+ Here is the call graph for this function:

◆ set() [1/11]

virtual void anch::sql::PreparedStatement::set ( std::size_t idx,
const anch::sql::Date & value )
virtual

Bind SQL date value to prepared statement

Parameters
idxthe prepared statement index parameter
valuethe value to bind
Exceptions
SqlExceptionany error
+ Here is the call graph for this function:

◆ set() [2/11]

virtual void anch::sql::PreparedStatement::set ( std::size_t idx,
const anch::sql::Time & value )
virtual

Bind SQL time value to prepared statement

Parameters
idxthe prepared statement index parameter
valuethe value to bind
Exceptions
SqlExceptionany error
+ Here is the call graph for this function:

◆ set() [3/11]

virtual void anch::sql::PreparedStatement::set ( std::size_t idx,
const anch::sql::Timestamp & value )
virtual

Bind SQL timestamp value to prepared statement

Parameters
idxthe prepared statement index parameter
valuethe value to bind
Exceptions
SqlExceptionany error
+ Here is the call graph for this function:

◆ set() [4/11]

void anch::sql::PreparedStatement::set ( std::size_t idx,
const char *const value )

Bind character array value to prepared statement

Parameters
idxthe prepared statement index parameter
valuethe value to bind
Exceptions
SqlExceptionany error
+ Here is the call graph for this function:

◆ set() [5/11]

void anch::sql::PreparedStatement::set ( std::size_t idx,
const std::string & value )

Bind string value to prepared statement

Parameters
idxthe prepared statement index parameter
valuethe value to bind
Exceptions
SqlExceptionany error
+ Here is the call graph for this function:

◆ set() [6/11]

void anch::sql::PreparedStatement::set ( std::size_t idx,
int16_t value )

Bind 16 bits signed integer value to prepared statement

Parameters
idxthe prepared statement index parameter
valuethe value to bind
Exceptions
SqlExceptionany error
+ Here is the call graph for this function:

◆ set() [7/11]

void anch::sql::PreparedStatement::set ( std::size_t idx,
int32_t value )

Bind 32 bits signed integer value to prepared statement

Parameters
idxthe prepared statement index parameter
valuethe value to bind
Exceptions
SqlExceptionany error
+ Here is the call graph for this function:

◆ set() [8/11]

void anch::sql::PreparedStatement::set ( std::size_t idx,
int64_t value )

Bind 64 bits signed integer value to prepared statement

Parameters
idxthe prepared statement index parameter
valuethe value to bind
Exceptions
SqlExceptionany error
+ Here is the call graph for this function:

◆ set() [9/11]

void anch::sql::PreparedStatement::set ( std::size_t idx,
uint16_t value )

Bind 16 bits unsigned integer value to prepared statement

Parameters
idxthe prepared statement index parameter
valuethe value to bind
Exceptions
SqlExceptionany error
+ Here is the call graph for this function:

◆ set() [10/11]

void anch::sql::PreparedStatement::set ( std::size_t idx,
uint32_t value )

Bind 32 bits unsigned integer value to prepared statement

Parameters
idxthe prepared statement index parameter
valuethe value to bind
Exceptions
SqlExceptionany error
+ Here is the call graph for this function:

◆ set() [11/11]

void anch::sql::PreparedStatement::set ( std::size_t idx,
uint64_t value )

Bind 64 bits unsigned integer value to prepared statement

Parameters
idxthe prepared statement index parameter
valuethe value to bind
Exceptions
SqlExceptionany error
+ Here is the call graph for this function:

Member Data Documentation

◆ _nbPlaceholders

std::size_t anch::sql::PreparedStatement::_nbPlaceholders
protected

Number of placeholders in SQL query

◆ _values

std::map<std::size_t,std::string> anch::sql::PreparedStatement::_values
protected

Statement values


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