AnewtDatabaseResultSet class

Database result set.

Class Overview

Database result set.

Result sets can be used to fetch or count rows returned by a database query.

You cannot instantiate AnewtDatabaseResultSet instances directly, instances of this class will be returned when an AnewtDatabasePreparedQuery is executed using AnewtDatabasePreparedQuery::prepare().

Public Methods

__construct($sql, $connection_handle, $result_set_handle)

Construct a new AnewtDatabaseResultSet instance (internal use).

Do not call this method directly; it is for internal use only.

(Note to backend implementors: you should override this constructor, call into the parent, and then store the n_rows and n_rows_affected values)

Parameters

$sql

The SQL query for this result set

$connection_handle

The internal connection handle

$result_set_handle

The internal result set handle

See also

free()

Free resources associated with this result set.

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

Row Fetching Methods

fetch_one()

Return the next row.

Return value

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

See also

fetch_all()

Return all remaining rows.

Return value

A numeric array containing the result rows as associative arrays. This may be an empty list.

See also

fetch_many($how_many)

Return up to the specified number of rows.

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

Parameters

$how_many

The number of rows to return. This must be a positive integer value.

Return value

A numeric array containing the result rows as associative arrays. This may be an empty list.

See also

Row Counting Methods

count()

Return the number of resulting rows in this result set.

Return value

The total number of result rows.

count_affected()

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

Return value

The total number of affected rows.

Helper Methods

obtain_field_types() [protected]

Deduce the data types in this result set.

This method should be implemented in backends to perform automatic type conversion.

cast_row(&$row) [protected]

Cast a row of data into native PHP data types.

This method should be implemented in backends to perform automatic type conversion.

Note that the array is modified in-place (and no result is returned).

Parameters

$row

A row of data.

Protected Attributes

$sql [protected]

The SQL query for this result set.

$connection_handle [protected]

The underlying database connection resource.

$result_set_handle [protected]

The underlying database result set resource.

$n_rows [protected]

The number of rows.

$n_rows_affected [protected]

The number of affected rows.

$field_types [protected]

The data types for the columns of this result set.