sptk2 logo
SPTK Home Page
Public Member Functions | Static Public Member Functions | List of all members
sptk::MySQLStatement Class Reference

#include <MySQLStatement.h>

Inheritance diagram for sptk::MySQLStatement:
sptk::DatabaseStatement< MySQLConnection, MYSQL_STMT >

Public Member Functions

 MySQLStatement (MySQLConnection *connection, String sql, bool autoPrepare)
 
 MySQLStatement (const MySQLStatement &)=delete
 
 MySQLStatement (MySQLStatement &&)=default
 
MySQLStatementoperator= (const MySQLStatement &)=delete
 
MySQLStatementoperator= (MySQLStatement &&)=default
 
void enumerateParams (QueryParameterList &queryParams) override
 
void setParameterValues () override
 
void prepare (const String &sql) const
 
void execute (bool) override
 
void bindResult (FieldList &fields)
 
void readResultRow (FieldList &fields)
 
void close () override
 
void fetch () override
 
- Public Member Functions inherited from sptk::DatabaseStatement< MySQLConnection, MYSQL_STMT >
MySQLConnection * connection () const
 
void statement (MYSQL_STMT *stmt)
 
MYSQL_STMT * statement () const
 
 DatabaseStatement (MySQLConnection *connection)
 
virtual ~DatabaseStatement ()=default
 
MYSQL_STMT * stmt () const
 
virtual void enumerateParams (QueryParameterList &queryParams)
 
CParamVectorenumeratedParams ()
 
size_t outputParameterCount () const
 
virtual void setParameterValues ()=0
 
virtual void execute (bool inTransaction)=0
 
virtual void close ()=0
 
virtual void fetch ()=0
 
bool eof () const
 
unsigned colCount () const
 

Static Public Member Functions

static VariantDataType mySQLTypeToVariantType (enum_field_types mysqlType)
 
static enum_field_types variantTypeToMySQLType (VariantDataType dataType)
 
static void dateTimeToMySQLDate (MYSQL_TIME &mysqlDate, DateTime timestamp, VariantDataType timeType)
 

Additional Inherited Members

- Protected Member Functions inherited from sptk::DatabaseStatement< MySQLConnection, MYSQL_STMT >
State & state ()
 

Detailed Description

MySQL statement wrapper

Constructor & Destructor Documentation

◆ MySQLStatement() [1/3]

sptk::MySQLStatement::MySQLStatement ( MySQLConnection *  connection,
String  sql,
bool  autoPrepare 
)

Constructor

Parameters
connectionConnection*, MySQL connection
sqlstd::string, SQL statement
autoPreparebool, If true then statement is executed as prepared.

◆ MySQLStatement() [2/3]

sptk::MySQLStatement::MySQLStatement ( const MySQLStatement )
delete

Deleted copy constructor

◆ MySQLStatement() [3/3]

sptk::MySQLStatement::MySQLStatement ( MySQLStatement &&  )
default

Move constructor

Member Function Documentation

◆ bindResult()

void sptk::MySQLStatement::bindResult ( FieldList fields)

Binds statement result metadata to query fields

Parameters
fieldsCFieldList&, query fields (if any)

◆ close()

void sptk::MySQLStatement::close ( )
overridevirtual

Closes statement and releases allocated resources

Implements sptk::DatabaseStatement< MySQLConnection, MYSQL_STMT >.

◆ dateTimeToMySQLDate()

static void sptk::MySQLStatement::dateTimeToMySQLDate ( MYSQL_TIME &  mysqlDate,
DateTime  timestamp,
VariantDataType  timeType 
)
static

Translates DateTime to MySQL time

Parameters
mysqlDateMYSQL_TIME&, MySQL time
timestampDateTime, Timestamp
timeTypeVariantType, Time type, VAR_DATE or VAR_DATETIME

◆ enumerateParams()

void sptk::MySQLStatement::enumerateParams ( QueryParameterList queryParams)
overridevirtual

Generates normalized list of parameters

Parameters
queryParamsCParamList&, Standard query parameters

Reimplemented from sptk::DatabaseStatement< MySQLConnection, MYSQL_STMT >.

◆ execute()

void sptk::MySQLStatement::execute ( bool  )
overridevirtual

◆ fetch()

void sptk::MySQLStatement::fetch ( )
overridevirtual

◆ mySQLTypeToVariantType()

static VariantDataType sptk::MySQLStatement::mySQLTypeToVariantType ( enum_field_types  mysqlType)
static

Translates MySQL native type to CVariant type

Parameters
mysqlTypeenum_field_types, MySQL native type
Returns
CVariant type

◆ operator=() [1/2]

MySQLStatement & sptk::MySQLStatement::operator= ( const MySQLStatement )
delete

Deleted copy assignment

◆ operator=() [2/2]

MySQLStatement & sptk::MySQLStatement::operator= ( MySQLStatement &&  )
default

Move assignment

◆ prepare()

void sptk::MySQLStatement::prepare ( const String sql) const

Prepares MySQL statement

Parameters
sqlconst std::string, statement SQL

◆ readResultRow()

void sptk::MySQLStatement::readResultRow ( FieldList fields)

Fetches statement result metadata to query fields

Parameters
fieldsCFieldList&, query fields (if any)

◆ setParameterValues()

void sptk::MySQLStatement::setParameterValues ( )
overridevirtual

Sets actual parameter values for the statement execution

Implements sptk::DatabaseStatement< MySQLConnection, MYSQL_STMT >.

◆ variantTypeToMySQLType()

static enum_field_types sptk::MySQLStatement::variantTypeToMySQLType ( VariantDataType  dataType)
static

Translates CVariant type to MySQL native type

Parameters
dataTypeVariantType&, CVariant type
Returns
MySQL native type

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

Fri Oct 14 2022 09:58:43: SPTK 5.4.1