xc
Public Member Functions | List of all members
Query Class Reference

SQL Statement execute / result. More...

#include <Query.h>

Public Member Functions

 Query (Database &dbin)
 Constructor accepting reference to database object. More...
 
 Query (Database &dbin, const std::string &sql)
 Constructor accepting reference to database object and query string to execute. More...
 
bool Connected ()
 Check if database object is connectable. More...
 
DatabaseGetDatabase () const
 Return reference to database object. More...
 
const std::string & GetLastQuery (void) const
 Return string containing last query executed. More...
 
bool execute (const std::string &sql)
 execute() returns true if query is successful, does not store result. More...
 
bool insert_blob1 (const std::string &sql, const void *blobData, const size_t &numBytes)
 Inserta un blob en la posiciĆ³n indicada por el primer signo de interrogaciĆ³n que aparece en la sentencia SQL.
 
sqlite3_stmt * get_result (const std::string &sql)
 Execute query and store result. More...
 
void free_result ()
 Free stored result, must be called after get_result() before calling execute()/get_result() again. More...
 
bool fetch_row (void)
 Fetch next result row. More...
 
sqlite_int64 insert_id ()
 Get id of last insert. More...
 
long num_rows (void) const
 Returns 0 if there are no rows to fetch.
 
size_t num_columns (void) const
 Return the number of columns of the query.
 
std::string field_names (void) const
 Return a string with the fields names.
 
int field_index (const std::string &str)
 
std::string getError (void) const
 Last error string. More...
 
int GetErrno ()
 Last error code. More...
 
const char * get_string (const std::string &sql)
 Execute query and return first result as a string. More...
 
long get_count (const std::string &sql)
 Execute query and return first result as a long integer. More...
 
double get_num (const std::string &sql)
 Execute query and return first result as a double. More...
 
bool is_null (int x)
 Check if column x in current row is null. More...
 
const void * getblob (const std::string &x)
 Return column named x as a blob value. More...
 
const void * getblob (int x)
 Return column x as a blob value. More...
 
const void * getblob ()
 Return next column as a string value - see rowcount. More...
 
const char * getstr (const std::string &x)
 Return column named x as a string value. More...
 
const char * getstr (int x)
 Return column x as a string value. More...
 
const char * getstr ()
 Return next column as a string value - see rowcount. More...
 
long getval (const std::string &x)
 Return column named x as a long integer. More...
 
long getval (int x)
 Return column x as a long integer. More...
 
long getval ()
 Return next column as a long integer - see rowcount. More...
 
unsigned long getuval (const std::string &x)
 Return column named x as an unsigned long integer. More...
 
unsigned long getuval (int x)
 Return column x as an unsigned long integer. More...
 
unsigned long getuval ()
 Return next column as an unsigned long integer. More...
 
int64_t getbigint (const std::string &x)
 Return column named x as a 64-bit integer value. More...
 
int64_t getbigint (int x)
 Return column x as a 64-bit integer value. More...
 
int64_t getbigint ()
 Return next column as a 64-bit integer value. More...
 
uint64_t getubigint (const std::string &x)
 Return column named x as an unsigned 64-bit integer value. More...
 
uint64_t getubigint (int x)
 Return column x as an unsigned 64-bit integer value. More...
 
uint64_t getubigint ()
 Return next column as an unsigned 64-bit integer value. More...
 
double getnum (const std::string &x)
 Return column named x as a double. More...
 
double getnum (int x)
 Return column x as a double. More...
 
double getnum ()
 Return next column as a double. More...
 

Detailed Description

SQL Statement execute / result.

Constructor & Destructor Documentation

◆ Query() [1/2]

Query::Query ( Database dbin)

Constructor accepting reference to database object.

◆ Query() [2/2]

Query::Query ( Database dbin,
const std::string &  sql 
)

Constructor accepting reference to database object and query string to execute.

Member Function Documentation

◆ Connected()

bool Query::Connected ( void  )

Check if database object is connectable.

◆ execute()

bool Query::execute ( const std::string &  sql)

execute() returns true if query is successful, does not store result.

◆ fetch_row()

bool Query::fetch_row ( void  )

Fetch next result row.

Returns
false if there was no row to fetch (end of rows)

◆ free_result()

void Query::free_result ( void  )

Free stored result, must be called after get_result() before calling execute()/get_result() again.

◆ get_count()

long Query::get_count ( const std::string &  sql)

Execute query and return first result as a long integer.

◆ get_num()

double Query::get_num ( const std::string &  sql)

Execute query and return first result as a double.

◆ get_result()

sqlite3_stmt * Query::get_result ( const std::string &  sql)

Execute query and store result.

◆ get_string()

const char * Query::get_string ( const std::string &  sql)

Execute query and return first result as a string.

◆ getbigint() [1/3]

int64_t Query::getbigint ( const std::string &  x)

Return column named x as a 64-bit integer value.

◆ getbigint() [2/3]

int64_t Query::getbigint ( int  x)

Return column x as a 64-bit integer value.

◆ getbigint() [3/3]

int64_t Query::getbigint ( )

Return next column as a 64-bit integer value.

◆ getblob() [1/3]

const void * Query::getblob ( const std::string &  x)

Return column named x as a blob value.

◆ getblob() [2/3]

const void * Query::getblob ( int  x)

Return column x as a blob value.

◆ getblob() [3/3]

const void * Query::getblob ( void  )

Return next column as a string value - see rowcount.

◆ GetDatabase()

Database & Query::GetDatabase ( ) const

Return reference to database object.

◆ GetErrno()

int Query::GetErrno ( void  )

Last error code.

◆ getError()

std::string Query::getError ( void  ) const

Last error string.

◆ GetLastQuery()

const std::string & Query::GetLastQuery ( void  ) const

Return string containing last query executed.

◆ getnum() [1/3]

double Query::getnum ( const std::string &  x)

Return column named x as a double.

◆ getnum() [2/3]

double Query::getnum ( int  x)

Return column x as a double.

◆ getnum() [3/3]

double Query::getnum ( void  )

Return next column as a double.

◆ getstr() [1/3]

const char * Query::getstr ( const std::string &  x)

Return column named x as a string value.

◆ getstr() [2/3]

const char * Query::getstr ( int  x)

Return column x as a string value.

◆ getstr() [3/3]

const char * Query::getstr ( void  )

Return next column as a string value - see rowcount.

◆ getubigint() [1/3]

uint64_t Query::getubigint ( const std::string &  x)

Return column named x as an unsigned 64-bit integer value.

◆ getubigint() [2/3]

uint64_t Query::getubigint ( int  x)

Return column x as an unsigned 64-bit integer value.

◆ getubigint() [3/3]

uint64_t Query::getubigint ( )

Return next column as an unsigned 64-bit integer value.

◆ getuval() [1/3]

unsigned long Query::getuval ( const std::string &  x)

Return column named x as an unsigned long integer.

◆ getuval() [2/3]

unsigned long Query::getuval ( int  x)

Return column x as an unsigned long integer.

◆ getuval() [3/3]

unsigned long Query::getuval ( void  )

Return next column as an unsigned long integer.

◆ getval() [1/3]

long Query::getval ( const std::string &  x)

Return column named x as a long integer.

◆ getval() [2/3]

long Query::getval ( int  x)

Return column x as a long integer.

◆ getval() [3/3]

long Query::getval ( void  )

Return next column as a long integer - see rowcount.

◆ insert_id()

sqlite_int64 Query::insert_id ( )

Get id of last insert.

◆ is_null()

bool Query::is_null ( int  x)

Check if column x in current row is null.


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