|
|||
|
|||
|
#include <m_sqlv2.h>
Inheritance diagram for SQLquery:


Public Member Functions | |
| SQLquery (const std::string &query) | |
| Initialize an SQLquery with a given format string only. | |
| SQLquery (const std::string &query, const ParamL ¶ms) | |
| Initialize an SQLquery with a format string and parameters. | |
| template<typename T> | |
| SQLquery & | operator, (const T &foo) |
| An overloaded operator for pushing parameters onto the parameter list. | |
| template<typename T> | |
| SQLquery & | operator% (const T &foo) |
| An overloaded operator for pushing parameters onto the parameter list. | |
Public Attributes | |
| std::string | q |
| The query 'format string'. | |
| ParamL | p |
| The query parameter list There should be one parameter for every ? character within the format string shown above. | |
C++ has no native type-safe way of having a variable number of arguments to a function, the workaround for this isn't easy to describe simply, but in a nutshell what's really happening when - from the above example - you do this:
SQLrequest foo = SQLrequest(this, target, "databaseid", SQLquery("SELECT (foo, bar) FROM rawr WHERE foo = '?' AND bar = ?", "Hello", "42"));
what's actually happening is functionally this:
SQLrequest foo = SQLrequest(this, target, "databaseid", query("SELECT (foo, bar) FROM rawr WHERE foo = '?' AND bar = ?").addparam("Hello").addparam("42"));
with 'query()' returning a reference to an object with a 'addparam()' member function which in turn returns a reference to that object. There are actually four ways you can create a SQLrequest..all have their disadvantages and advantages. In the real implementations the 'query()' function is replaced by the constructor of another class 'SQLquery' which holds the query string and a ParamL (std::deque<std::string>) of query parameters. This is essentially the same as the above example except 'addparam()' is replaced by operator,(). The full syntax for this method is:
SQLrequest foo = SQLrequest(this, target, "databaseid", (SQLquery("SELECT.. ?"), parameter, parameter));
Definition at line 152 of file m_sqlv2.h.
|
|
Initialize an SQLquery with a given format string only.
|
|
||||||||||||
|
Initialize an SQLquery with a format string and parameters. If you provide parameters, you must initialize the list yourself if you choose to do it via this method, using std::deque::push_back(). |
|
||||||||||
|
An overloaded operator for pushing parameters onto the parameter list. This has higher precedence than 'operator,' and can save on parenthesis. Definition at line 191 of file m_sqlv2.h. References ConvToStr(), and p. |
|
||||||||||
|
An overloaded operator for pushing parameters onto the parameter list.
Definition at line 182 of file m_sqlv2.h. References ConvToStr(), and p. |
|
|
The query parameter list There should be one parameter for every ? character within the format string shown above.
Definition at line 162 of file m_sqlv2.h. Referenced by SQLConnection::DoLeadingQuery(), SQLConn::DoQuery(), operator%(), operator,(), and SQLConn::Query(). |
|
|
The query 'format string'.
Definition at line 157 of file m_sqlv2.h. Referenced by SQLConn::DoConnectedPoll(), SQLConnection::DoLeadingQuery(), SQLConn::DoQuery(), and SQLConn::Query(). |