Main Page   Namespace List   Class Hierarchy   Compound List   File List   Namespace Members   Compound 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:

Inheritance graph
[legend]
Collaboration diagram for mysqlpp::ResUse:

Collaboration graph
[legend]
List of all members.

Public Methods

 ResUse ()
 Default constructor.

 ResUse (MYSQL_RES *result, Connection *m=0, bool te=false)
 Create the object, fully initialized.

 ResUse (const ResUse &other)
 Create a copy of another ResUse object.

 ~ResUse ()
 Destroy object.

ResUse & operator= (const ResUse &other)
 Copy another ResUse object's data into this object.

MYSQL_RES * mysql_result ()
 Return raw MySQL C API result set.

Row fetch_row ()
 Wraps mysql_fetch_row() in MySQL C API.

bool eof () const
 Wraps mysql_eof() in MySQL C API.

unsigned long * fetch_lengths () const
 Wraps mysql_fetch_lengths() in MySQL C API.

Fieldfetch_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.

FieldNamesfield_names ()
 Get the names of the fields within this result set.

const FieldNamesfield_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_infofield_type (int i)
 Get the MySQL type for a field given its index.

const mysql_type_infofield_type (int) const
 Get the MySQL type for a field given its index.

FieldTypesfield_types ()
 Get a list of the types of the fields within this result set.

const FieldTypesfield_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().

FieldNamesnames ()
 Alias for field_names().

const FieldNamesnames () const
 Alias for field_names().

void reset_names ()
 Alias for reset_field_names().

mysql_type_infotypes (int i)
 Alias for field_type().

const mysql_type_infotypes (int i) const
 Alias for field_type().

FieldTypestypes ()
 Alias for field_types().

const FieldTypestypes () const
 Alias for field_types().

void reset_types ()
 Alias for reset_field_types().

const Fieldsfields () const
 Get the underlying Fields structure.

const Fieldfields (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 Methods

void copy (const ResUse &other)
 copy another ResUse object's contents into this one.


Protected Attributes

Connectionmysql
 server result set comes from

MYSQL_RES * mysql_res
 underlying C API result set

bool throw_exceptions
 if true, throw exceptions on errors

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.

Not to be used on the self. 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    [inline]
 

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 [inline]
 

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:
Generated on Thu May 26 09:40:37 2005 for MySQL++ by doxygen1.2.18