Main Page | Namespace List | Class Hierarchy | Class List | File List | Namespace Members | Class Members | File Members

# mysqlpp::ResUse Class Reference

A basic result set class, for use with "use" queries. More...

`#include <result.h>`

Inheritance diagram for mysqlpp::ResUse:

[legend]
Collaboration diagram for mysqlpp::ResUse:

[legend]
List of all members.

## Public Member Functions
| ResUse ()
| Default constructor.
| ResUse (MYSQL_RES *result, Connection *c=0, bool te=true)
| Create the object, fully initialized.
| ResUse (const ResUse &other)
| Create a copy of another ResUse object.
virtual | ~ResUse ()
| Destroy object.
ResUse & | operator= (const ResUse &other)
| Copy another ResUse object's data into this object.
MYSQL_RES * | raw_result ()
| Return raw MySQL C API result set.
Row | fetch_row ()
| Wraps mysql_fetch_row() in MySQL C API.
unsigned long * | fetch_lengths () const
| Wraps mysql_fetch_lengths() in MySQL C API.
Field & | fetch_field () const
| Wraps mysql_fetch_field() in MySQL C API.
void | field_seek (int field)
| Wraps mysql_field_seek() in MySQL C API.
int | num_fields () const
| Wraps mysql_num_fields() in MySQL C API.
void | parent_leaving ()
| Documentation needed!
void | purge ()
| Free all resources held by the object.
| operator bool () const
| Return true if we have a valid result set.
unsigned int | columns () const
| Return the number of columns in the result set.
std::string & | table ()
| Get the name of table that the result set comes from.
const std::string & | table () const
| Return the name of the table.
int | field_num (const std::string &) const
| Get the index of the named field.
std::string & | field_name (int)
| Get the name of the field at the given index.
const std::string & | field_name (int) const
| Get the name of the field at the given index.
FieldNames & | field_names ()
| Get the names of the fields within this result set.
const FieldNames & | field_names () const
| Get the names of the fields within this result set.
void | reset_field_names ()
| Reset the names in the field list to their original values.
mysql_type_info & | field_type (int i)
| Get the MySQL type for a field given its index.
const mysql_type_info & | field_type (int) const
| Get the MySQL type for a field given its index.
FieldTypes & | field_types ()
| Get a list of the types of the fields within this result set.
const FieldTypes & | field_types () const
| Get a list of the types of the fields within this result set.
void | reset_field_types ()
| Reset the field types to their original values.
int | names (const std::string &s) const
| Alias for field_num().
std::string & | names (int i)
| Alias for field_name().
const std::string & | names (int i) const
| Alias for field_name().
FieldNames & | names ()
| Alias for field_names().
const FieldNames & | names () const
| Alias for field_names().
void | reset_names ()
| Alias for reset_field_names().
mysql_type_info & | types (int i)
| Alias for field_type().
const mysql_type_info & | types (int i) const
| Alias for field_type().
FieldTypes & | types ()
| Alias for field_types().
const FieldTypes & | types () const
| Alias for field_types().
void | reset_types ()
| Alias for reset_field_types().
const Fields & | fields () const
| Get the underlying Fields structure.
const Field & | fields (unsigned int i) const
| Get the underlying Field structure given its index.
bool | operator== (const ResUse &other) const
| Returns true if the other ResUse object shares the same underlying C API result set as this one.
bool | operator!= (const ResUse &other) const
| Returns true if the other ResUse object has a different underlying C API result set from this one.
## Protected Member Functions
void | copy (const ResUse &other)
| Copy another ResUse object's contents into this one.
## Protected Attributes
Connection * | conn_
| server result set comes from
MYSQL_RES * | result_
| underlying C API result set
bool | initialized_
| if true, object is fully initted
FieldNames * | names_
| list of field names in result
FieldTypes * | types_
| list of field types in result
Fields | fields_
| list of fields in result
std::string | table_
| table result set comes from

## Detailed Description

A basic result set class, for use with "use" queries.

A "use" query is one where you make the query and then process just one row at a time in the result instead of dealing with them all as a single large chunk. (The name comes from the MySQL C API function that initiates this action, `mysql_use_result()`.) By calling fetch_row() until it throws a mysqlpp::BadQuery exception (or an empty row if exceptions are disabled), you can process the result set one row at a time.

## Member Function Documentation

void mysqlpp::ResUse::copy | ( | const ResUse & | other | ) | `[protected]`

| Copy another ResUse object's contents into this one. Self-copy is not allowed.

Row mysqlpp::ResUse::fetch_row | ( |  | ) | `[inline]`

| Wraps mysql_fetch_row() in MySQL C API. This is not a thin wrapper. It does a lot of error checking before returning the mysqlpp::Row object containing the row data.

std::string & mysqlpp::ResUse::field_name | ( | int |  | ) |

| Get the name of the field at the given index. This is the inverse of field_num().

int mysqlpp::ResUse::field_num | ( | const std::string & |  | ) | const

| Get the index of the named field. This is the inverse of field_name().

mysqlpp::ResUse::operator bool | ( |  | ) | const`[inline]`

| Return true if we have a valid result set. This operator is primarily used to determine if a query was successful:
                  Query q("....");
                  if (q.use()) {
                      ...
Query::use() returns a ResUse object, and it won't contain a valid result set if the query failed.

bool mysqlpp::ResUse::operator== | ( | const ResUse & | other | ) | const`[inline]`

| Returns true if the other ResUse object shares the same underlying C API result set as this one. This works because the underlying result set is stored as a pointer, and thus can be copied and then compared.

void mysqlpp::ResUse::purge | ( |  | ) | `[inline]`

| Free all resources held by the object. This class's destructor is little more than a call to purge(), so you can think of this as a way to re-use a ResUse object, to avoid having to completely re-create it.

const std::string& mysqlpp::ResUse::table | ( |  | ) | const`[inline]`

| Return the name of the table. This is only valid

The documentation for this class was generated from the following files:

- result.h
- result.cpp