Public Types | |
enum | Type { SimpleType, ArgumentType, BulkArgumentType } |
Public Member Functions | |
Query (const std::string &sql) | |
Query (const std::string &sql, const std::string &args) | |
Query (const std::string &sql, const std::vector< std::string > &bulkArgs) | |
const std::string & | arguments () const |
const std::vector< std::string > & | bulkArguments () const |
bool | hasArguments () const |
bool | hasBulkArguments () const |
void | setArguments (const std::string &args) |
void | setBulkArguments (const std::vector< std::string > &bulkArgs) |
void | setStatement (const std::string &sql) |
const std::string & | statement () const |
Type | type () const |
The class Query provides the possibility to conveniently define simple SQL statements, statements with parameter substitution, as well as statements for bulk operations. The actual type of a Query is accessible through type().
All three types can be defined either by using the corresponding constructor or by using the property based approach. To select all rows of a table called "players" write directly
or set the appropriate properties individually
In order to prepare a statement with arguments (parameter substitution) use placeholders:
For a bulk operation, finally, use:
|
explicit |
Constructs a query with the SQL statement sql.
CppCrate::Query::Query | ( | const std::string & | sql, |
const std::string & | args | ||
) |
Constructs a query with the SQL statement sql and the parameters args.
CppCrate::Query::Query | ( | const std::string & | sql, |
const std::vector< std::string > & | bulkArgs | ||
) |
Constructs a query with the SQL statement sql and the bulk arguments bulkArgs.
const std::string & CppCrate::Query::arguments | ( | ) | const |
Returns the parameters.
const std::vector< std::string > & CppCrate::Query::bulkArguments | ( | ) | const |
Returns the bulk arguments.
bool CppCrate::Query::hasArguments | ( | ) | const |
Returns whether the query has parameters defined.
bool CppCrate::Query::hasBulkArguments | ( | ) | const |
Returns whether the query has bulk arguments defined.
void CppCrate::Query::setArguments | ( | const std::string & | args | ) |
Sets the parameters to args.
void CppCrate::Query::setBulkArguments | ( | const std::vector< std::string > & | bulkArgs | ) |
Sets the bulk arguments to bulkArgs.
void CppCrate::Query::setStatement | ( | const std::string & | sql | ) |
Sets the SQL statement to sql.
const std::string & CppCrate::Query::statement | ( | ) | const |
Returns the SQL statement.
Query::Type CppCrate::Query::type | ( | ) | const |
Returns the query's type.