#include <sql_query.h>
Inheritance diagram for mysqlpp::SQLQuery:
Public Methods | |
SQLQuery () | |
Default constructor. | |
SQLQuery (const SQLQuery &q) | |
Create a query as a copy of another. | |
void | parse () |
Treat the contents of the query string as a template query. | |
std::string | error () const |
Return the last error message that was set. | |
bool | success () const |
Return true if the last query was successful. | |
operator bool () | |
Return true if the last query was successful. | |
bool | operator! () |
Return true if the last query failed. | |
void | reset () |
Reset the query object so that it can be reused. | |
template<class T> SQLQuery & | update (const T &o, const T &n) |
Build an UPDATE SQL query. | |
template<class T> SQLQuery & | insert (const T &v) |
Build an INSERT SQL query for one record. | |
template<class Iter> SQLQuery & | insert (Iter first, Iter last) |
Build an INSERT SQL query for multiple records. | |
template<class T> SQLQuery & | replace (const T &v) |
Build a REPLACE SQL query. | |
std::string | str () |
Get built query as a null-terminated C++ string. | |
std::string | str (query_reset r) |
Get built query as a null-terminated C++ string. | |
std::string | str (SQLQueryParms &p) |
Get built query as a null-terminated C++ string. | |
std::string | str (SQLQueryParms &p, query_reset r) |
Get built query as a null-terminated C++ string. | |
Public Attributes | |
SQLQueryParms | def |
The default template parameters. | |
Protected Types | |
typedef const SQLString & | ss |
to keep parameters lists short | |
typedef SQLQueryParms | parms |
abstraction; remove when Query and SQLQuery merge | |
Protected Methods | |
void | proc (SQLQueryParms &p) |
Process a parameterized query list. | |
Protected Attributes | |
bool | Success |
if true, last query succeeded | |
char * | errmsg |
string explaining last query error | |
std::vector< SQLParseElement > | parsed |
List of template query parameters. | |
std::vector< std::string > | parsed_names |
Maps template parameter position values to the corresponding parameter name. | |
std::map< std::string, int > | parsed_nums |
Maps template parameter names to their position value. |
One uses an object of this class to form queries that can be sent to the database server via the mysqlpp::Connection object.
This class is subclassed from std::stringstream
. This means that you can form a SQL query using C++ stream idioms without having to create your own stringstream
object and then dump that into the query object. And of course, it gets you all the benefits of C++ streams, such as type safety, which sprintf()
and such do not offer. Although you can read from this object as you would any other stream, this is not recommended. It may fail in strange ways, and there is no support offered if you break it by doing so.
If you seek within the stream in any way, be sure to reset the stream pointer to the end before calling any of the SQLQuery-specific methods except for error() and success().
|
Return the last error message that was set. This function has no real meaning at this level. It's overridden with useful behavior in the Query subclass. |
|
Build an INSERT SQL query for multiple records.
Reimplemented in mysqlpp::Query. |
|
Build an INSERT SQL query for one record.
Reimplemented in mysqlpp::Query. |
|
Treat the contents of the query string as a template query. This method sets up the internal structures used by all of the other members that accept template query parameters. See the "Template Queries" chapter in the user manual for more information. |
|
Build a REPLACE SQL query.
Reimplemented in mysqlpp::Query. |
|
Reset the query object so that it can be reused. This erases the query string and the contents of the parameterized query element list. |
|
Get built query as a null-terminated C++ string.
|
|
Get built query as a null-terminated C++ string.
|
|
Get built query as a null-terminated C++ string.
|
|
Build an UPDATE SQL query.
Reimplemented in mysqlpp::Query. |
|
The default template parameters. Used for filling in parameterized queries. |