clang-tags
C/C++ source code indexing tool based on libclang
 All Classes Functions Variables Typedefs Groups Pages
Classes | Public Member Functions | List of all members
Sqlite::Statement Class Reference

Prepared SQL statement. More...

#include <statement.hxx>

Classes

struct  Statement_

Public Member Functions

 Statement (Sqlite::Database &db, char const *const sql)
 Constructor.
Statementbind (const std::string &s)
 Bind a placeholder to a value.
Statementbind (int i)
 Bind a placeholder to a value.
Statementoperator>> (int &i)
 Extract an int value from the current result row.
Statementoperator>> (std::string &s)
 Extract a value from the current result row.
int step ()
 Execute the statement or fetch the next result row.

Detailed Description

Prepared SQL statement.

Objects of this type represent prepared SQL statements destined to be executed on an SQLite database.

Prepared SQL statements can have placeholders (written as question marks '?' in the SQL request) which can be bound to real values (see bind) before being executed (see step).

Values can be extracted from the query results using operator>>().

Constructor & Destructor Documentation

Sqlite::Statement::Statement ( Sqlite::Database db,
char const *const  sql 
)
inline

Constructor.

Create a prepared statement for a SQL request on a given SQLite database connection.

Parameters
dbSQLite Database connection
sqlSQL request
Exceptions
Error

Member Function Documentation

Statement& Sqlite::Statement::bind ( const std::string &  s)
inline

Bind a placeholder to a value.

This method should be used for all value types except int. This method returns the Statement object itself, allowing chains of calls.

Parameters
sstring representing the value to be bound
Returns
the Statement object itself
Statement& Sqlite::Statement::bind ( int  i)
inline

Bind a placeholder to a value.

This method should be used for int values. This method returns the Statement object itself, allowing chains of calls.

Parameters
iinteger value to be bound
Returns
the Statement object itself
Statement& Sqlite::Statement::operator>> ( int &  i)
inline

Extract an int value from the current result row.

This method returns the Statement object itself, allowing chains of calls.

Parameters
ivariable where the value will be stored
Returns
the Statement object itself
Statement& Sqlite::Statement::operator>> ( std::string &  s)
inline

Extract a value from the current result row.

This method should be called for all value types except int. It returns the Statement object itself, allowing chains of calls.

Parameters
svariable where the value will be stored
Returns
the Statement object itself
int Sqlite::Statement::step ( )
inline

Execute the statement or fetch the next result row.

Execute the SQL statement, after all placeholders have been bound. If no results are produced by the statement, return SQLITE_OK. Otherwise, fetch the first result row and return SQLITE_ROW.

Fetch a new row and return SQLITE_ROW for all subsequent calls. When no more rows are available, return SQLITE_DONE.

Values can be extracted from the current result row using operator>>().

Returns
SQLITE_OK, SQLITE_ROW or SQLITE_DONE
Exceptions
Error

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