ResultSet class

Class representing database result sets.

Class Overview

Class representing database result sets.

Several methods are available to fetch the actual data from the database.

Public Methods

ResultSet($sql, &$backend)

Constructor executes the query.

query_type()

Find out the type of the query for this ResultSet instance.

Return value

The type of the query. These are constants like ANEWT_DATABASE_SQL_QUERY_TYPE_SELECT and ANEWT_DATABASE_SQL_QUERY_TYPE_INSERT.

free()

Free resources associated with this result set.

You cannot use any methods on the result set instance anymore after calling this method.

This method should be overridden using backend-specific code.

fetch()

Returns the next row in this result set.

Return value

An associative array containing all fields of the next result row from the result set.

See also

fetch_all()

Returns all remaining rows from the current resultset.

Return value

A numeric array containing the result rows as associative array (may be an empty list).

See also

fetch_many($num=1)

Returns the specified number of rows from the current resultset.

Note that the actual number of rows may be lower than the value specified, since there may be less rows in the set.

Parameters

$num

The number of rows to return (optional, defaults to 1).

Return value

A numeric array containing the result rows as associative array (the list may contain less than $num rows, or may even be empty).

See also

count()

Returns the number of resulting rows in this resultset.

This method might not be available for some databases (it works at least with MySQL and PostgreSQL though).

Return value

The total number of result rows.

count_affected()

Returns the number of rows that where affected by the last executed query.

This method might nog be available for some databases (it works at least with MySQL and PostgreSQL though).

Private Methods

deduce_types() [private]

Deduces the data types in this result set.

This method can be implemented in backends to do automatic type conversion.

cast_row(&$row) [private]

Casts a row of data into native PHP data types.

The array is modified in-place and no result is returned. This method can be implemented in backend to do automatic type conversion.

Parameters

$row

A row of data.