#include <SQLFetcher.hh>
Inherited by fatalmind::mysql::EscalateWarnings, fatalmind::SQL::NopSQLFetcher, and PrintFetcher.
To fetch data you must derive a "Fetcher" from this class and pass it to SQLSelect or SQLSelectRow constructor. For each retrieved row the bound output parameters are set and the process() method is invoked. Implementations can stop the retrieval by returning "false" from their process() implementation.
Optionally you can also overwrite the done() method which is called when the retrieval has finished.
The usage of a Fetcher is the only way to retrieve multiple rows and it is therefore an mandatory parameter to all SQLSelect constructors. For single row fetching via SQLSelectRow a fetcher class is an optional parameter, alternativley you can just access the output parameters after completion of the SQLSelectRow command.
It is best current pratice to let your SQLFetcher implementation own the actual bindout varaibles. Please have a look at the select.cc example.
Please also not that it is currently the callers responsibility to make sure the SQLFetcher instance which is passed to SQLSelect or SQLSelectRow remains valid for the complete lifetime of the respective SQLSelect object since it is used by reference (very bad practice).
Public Member Functions | |
virtual bool | process (int row)=0 |
This method is to be overwritten by the user and will be invoked for each row. | |
virtual void | done (bool more, int fetched) |
This method is called if all records were fetched succesfully. |
virtual bool fatalmind::SQL::SQLFetcher::process | ( | int | row | ) | [pure virtual] |
This method is to be overwritten by the user and will be invoked for each row.
The variables you have bound are filled accordingly.
As implementor of this method you may chose to stop fetching of more data. You can do so by returning false.
[in] | row | The rownumber to be processed. Starting at 0. |
false - to stop fetching and terminate the SQLSelect execution
virtual void fatalmind::SQL::SQLFetcher::done | ( | bool | more, | |
int | fetched | |||
) | [inline, virtual] |
This method is called if all records were fetched succesfully.
This method will NOT be called if execution was aborted because of an exception.
The default implementation does nothing.
[in] | more | Indicates if all data was fetched (false) or if (eventually) more data could have been fetched (true). |
[in] | fetched | The number of records fetched |