AnCH Framework 0.2
Another C++ Hack: C++23 utility libraries
Loading...
Searching...
No Matches
anch::sql::MySQLPreparedStatement Class Reference

MySQL prepared statement implementation. More...

#include <mysqlPreparedStatement.hpp>

Inheritance diagram for anch::sql::MySQLPreparedStatement:
Collaboration diagram for anch::sql::MySQLPreparedStatement:

Public Member Functions

 MySQLPreparedStatement (MYSQL *dbCon, const std::string &query)
virtual ~MySQLPreparedStatement () noexcept
Public Member Functions inherited from anch::sql::PreparedStatement
 PreparedStatement () noexcept
 PreparedStatement (const PreparedStatement &)=delete
virtual ~PreparedStatement () noexcept
ResultSet * executeQuery ()
uint64_t executeUpdate ()
template<anch::sql::Bindable T>
void set (std::string_view name, const T &value)
void setNull (std::string_view name)
void set (const anch::sql::Parameters &parameters)
template<anch::Described T>
void set (const anch::sql::FieldsOf< T > &fields)
void clearParameters () noexcept
std::size_t getParameterCount () const noexcept
const std::vector< std::string > & getParameterNames () const noexcept
const std::string & getQuery () const noexcept
std::size_t getBindingCount () const noexcept
const anch::sql::ParameterValue & getBindingValue (std::size_t idx) const

Protected Member Functions

virtual void doPrepare (const std::string &query) override
virtual ResultSet * doExecuteQuery () override
virtual uint64_t doExecuteUpdate () override
Protected Member Functions inherited from anch::sql::PreparedStatement
std::string parse (const std::string &query, const anch::sql::SqlSyntax &syntax, anch::sql::ParameterStyle style)
virtual void deallocate () noexcept
void invalidate () noexcept

Additional Inherited Members

Protected Attributes inherited from anch::sql::PreparedStatement
std::string _query
std::vector< std::string > _names
std::vector< anch::sql::ParameterValue > _values
std::vector< std::optional< anch::sql::ParameterList > > _lists
std::vector< bool > _bound
std::vector< anch::sql::NamedQuery::Binding > _bindings
std::optional< anch::sql::NamedQuery > _named
anch::sql::ParameterStyle _style
std::string _prepared
std::vector< std::size_t > _shape

Detailed Description

MySQL prepared statement implementation.

Compile prepared statement in constructor, manage bind and statement execution.

Author
Vincent Lachenal
Since
0.1

Constructor & Destructor Documentation

◆ MySQLPreparedStatement()

anch::sql::MySQLPreparedStatement::MySQLPreparedStatement ( MYSQL * dbCon,
const std::string & query )

MySQLPreparedStatement constructor

Parameters
dbConthe database connection
querythe SQL query
Exceptions
SqlExceptionany error

◆ ~MySQLPreparedStatement()

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

Member Function Documentation

◆ doExecuteQuery()

virtual ResultSet * anch::sql::MySQLPreparedStatement::doExecuteQuery ( )
overrideprotectedvirtual

Execute prepared statement for SELECT statement

Returns
the result set
Exceptions
SqlExceptionany error

Implements anch::sql::PreparedStatement.

Here is the call graph for this function:

◆ doExecuteUpdate()

virtual uint64_t anch::sql::MySQLPreparedStatement::doExecuteUpdate ( )
overrideprotectedvirtual

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

Returns
the number of affected rows
Exceptions
SqlExceptionany error

Implements anch::sql::PreparedStatement.

Here is the call graph for this function:

◆ doPrepare()

virtual void anch::sql::MySQLPreparedStatement::doPrepare ( const std::string & query)
overrideprotectedvirtual

Prepare query (statement prepared again when bound lists change the query)

Parameters
querythe query to prepare
Exceptions
SqlExceptionany error

Implements anch::sql::PreparedStatement.

Here is the call graph for this function:

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