Dv::MySql::CommandImpl Class Reference
MySql specific implementation class for Sql::Command.
More...
#include <mysqldb.h>
List of all members.
Private Member Functions |
| CommandImpl (Db &db, Sql::Command &cmd) |
virtual | ~CommandImpl () |
| Destructor.
|
std::string | mysql_error_message (const std::string &msg) |
| Fetch mysql errror message.
|
void | sync (unsigned int row) throw (std::logic_error) |
| Synchronize cursor to point to row number r .
|
Db & | db () |
| Return error code.
|
void | exec () throw (std::runtime_error) |
| Execute this command.
|
void | fetch (std::vector< std::string > &data, unsigned int row) throw (std::logic_error) |
| Fetch row from query result.
|
void | fetch (std::vector< std::string > &v, std::vector< bool > &nulls, unsigned int r) throw (std::logic_error) |
| Fetch r'th row of query result and set corresponding null flags.
|
void | fetch (std::string &data, unsigned int row, unsigned int column) throw (std::logic_error) |
| Fetch c'th element in r'th row of query result.
|
const char * | fetch_data_ptr (unsigned int row, unsigned int column, size_t &size) throw (std::logic_error) |
| Grab a pointer to column of a row in the query result.
|
void | escape (const std::string &s) |
| Write quoted and escaped version of parameter to textstream().
|
void | table (Dv::Sql::Table::Ref &table) const throw (std::logic_error) |
unsigned int | insertid () const |
| Auto_increment insertid of last query.
|
Private Attributes |
Db & | db_ |
void * | result_ |
int | row_ |
unsigned long * | lengths_ |
void * | mrow_ |
bool | ran_ |
Friends |
class | Db |
Detailed Description
MySql specific implementation class for Sql::Command.
Definition at line 226 of file mysqldb.h.
Constructor & Destructor Documentation
Dv::MySql::CommandImpl::CommandImpl |
( |
Db & |
db, |
|
|
Sql::Command & |
cmd | |
|
) |
| | [private] |
virtual Dv::MySql::CommandImpl::~CommandImpl |
( |
|
) |
[private, virtual] |
Member Function Documentation
std::string Dv::MySql::CommandImpl::mysql_error_message |
( |
const std::string & |
msg |
) |
[private] |
Fetch mysql errror message.
- Parameters:
-
- Returns:
- mysql specific message or default message is none is available
void Dv::MySql::CommandImpl::sync |
( |
unsigned int |
row |
) |
throw (std::logic_error) [private] |
Synchronize cursor to point to row number r
.
- Parameters:
-
| row | number to make cursor (mrow_ ) point to. |
- Exceptions:
-
| std::logic_error | if the operation fails. |
Db& Dv::MySql::CommandImpl::db |
( |
|
) |
[inline, private, virtual] |
void Dv::MySql::CommandImpl::exec |
( |
|
) |
throw (std::runtime_error) [private, virtual] |
void Dv::MySql::CommandImpl::fetch |
( |
std::vector< std::string > & |
data, |
|
|
unsigned int |
row | |
|
) |
| | throw (std::logic_error) [private, virtual] |
Fetch row from query result.
Note that NULL values will be stored as "NULL" strings.
This function is part of the Sql::CommandImpl required interface.
- Parameters:
-
| data | to append row data to |
| row | number of row to retrieve data from |
- Exceptions:
-
| std::logic_error | if row not available |
Implements Dv::Sql::CommandImpl.
void Dv::MySql::CommandImpl::fetch |
( |
std::vector< std::string > & |
v, |
|
|
std::vector< bool > & |
nulls, |
|
|
unsigned int |
r | |
|
) |
| | throw (std::logic_error) [private, virtual] |
Fetch r'th row of query result and set corresponding null flags.
This function is part of the Sql::CommandImpl required interface.
- Parameters:
-
| v | column values will be appended to this vector, a NULL value will be appended as an empty string |
| nulls | one value (true iff the column value is NULL) for each column will be appended to this vector |
| r | number of row in result to retrieve values for |
- Exceptions:
-
| std::logic_error | if row not available |
Implements Dv::Sql::CommandImpl.
void Dv::MySql::CommandImpl::fetch |
( |
std::string & |
data, |
|
|
unsigned int |
row, |
|
|
unsigned int |
column | |
|
) |
| | throw (std::logic_error) [private, virtual] |
Fetch c'th element in r'th row of query result.
This function is part of the Sql::CommandImpl required interface.
- Parameters:
-
| data | where column value is to be stored |
| row | number to retrieve |
| column | number in row to retrieve |
- Exceptions:
-
| std::logic_error | if row or column not available |
Reimplemented from Dv::Sql::CommandImpl.
const char* Dv::MySql::CommandImpl::fetch_data_ptr |
( |
unsigned int |
row, |
|
|
unsigned int |
column, |
|
|
size_t & |
size | |
|
) |
| | throw (std::logic_error) [private, virtual] |
Grab a pointer to column of a row in the query result.
This low-level function avoids copying from the mysql query result. It simply returns a pointer to the start of the relevant data and sets size to the size of the data. It may be usefule to process e.g. large blobs.
Dv::Sql::Command q(...);
q.exec();
for (size_t r=0; r<q.nrows(); ++r) {
size_t size;
const char* begin = q.fetch_data_ptr(r, 0, size);
std::copy(begin, begin+size, std::ostream_iterator<char>(std::cout, '\n');
}
- Parameters:
-
| row | number of row containing the data |
| column | number of the column in the row containin the data |
| size | output parameter: will be set to the size of the data |
- Returns:
- a pointer to the start of the data
-
0 iff the relevant column in the row is NULL
Implements Dv::Sql::CommandImpl.
void Dv::MySql::CommandImpl::escape |
( |
const std::string & |
s |
) |
[private, virtual] |
void Dv::MySql::CommandImpl::table |
( |
Dv::Sql::Table::Ref & |
table |
) |
const throw (std::logic_error) [private, virtual] |
unsigned int Dv::MySql::CommandImpl::insertid |
( |
|
) |
const [private, virtual] |
Auto_increment insertid of last query.
- Returns:
- auto_increment insertid of last query
Reimplemented from Dv::Sql::CommandImpl.
Friends And Related Function Documentation
Member Data Documentation
The documentation for this class was generated from the following file: