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

# mysqlpp::Row Class Reference

Manages rows from a result set. More...

`#include <row.h>`

Inheritance diagram for mysqlpp::Row:

[legend]
Collaboration diagram for mysqlpp::Row:

[legend]
List of all members.

## Public Methods
| Row ()
| Default constructor.
| Row (MYSQL_ROW d, const ResUse *r, unsigned long *jj, bool te=false)
| Create a row object.
| ~Row ()
| Destroy object.
const Row & | self () const
| Get a const reference to this object.
Row & | self ()
| Get a reference to this object.
const ResUse & | parent () const
| Get a reference to our parent class.
size_type | size () const
| Get the number of fields in the row.
const ColData | operator[] (size_type i) const
| Get the value of a field given its index.
const ColData | lookup_by_name (const char *) const
| Get the value of a field given its field name.
const char * | raw_data (int i) const
| Return the value of a field given its index, in raw form.
| operator bool () const
| Returns true if there is data in the row.

## Detailed Description

Manages rows from a result set.

## Constructor & Destructor Documentation

mysqlpp::Row::Row | ( | MYSQL_ROW | d,
|  | const ResUse * | r,
|  | unsigned long * | jj,
|  | bool | te = false
| ) | `[inline]`

  | Create a row object. Parameters:
  d | MySQL C API row data
  r | result set that the row comes from
  jj | length of each item in d
  te | if true, throw exceptions on errors

## Member Function Documentation

const ColData mysqlpp::Row::lookup_by_name | ( | const char * |  | ) | const

| Get the value of a field given its field name. This function is rather inefficient. You should use operator[] if you're using Rows directly, or SSQLS for efficient named access to row elements.

const ColData mysqlpp::Row::operator[] | ( | size_type | i | ) | const

| Get the value of a field given its index. If the array index is out of bounds, the C++ standard says that the underlying vector container should throw an exception. Whether it actually does is probably implementation-dependent. Note that we return the ColData object by value. The purpose of ColData is to make it easy to convert the string data returned by the MySQL server to some more appropriate type, so you're almost certain to use this operator in a construct like this:
                 string s = row[2];
That accesses the third field in the row, returns a temporary ColData object, which is then automatically converted to a `std::string` and copied into `s`. That works fine, but beware of this similar but incorrect construct:
                 const char* pc = row[2];
This one line of code does what you expect, but `pc` is then a dangling pointer: it points to memory owned by the temporary ColData object, which will have been destroyed by the time you get around to actually using the pointer.

const char* mysqlpp::Row::raw_data | ( | int | i | ) | const`[inline]`

| Return the value of a field given its index, in raw form. This is the same thing as operator[], except that the data isn't converted to a ColData object first. Also, this method does not check for out-of-bounds array indices.

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

- row.h
- row.cpp