lib/MTk/DBQuery.pm


NAME

MTk::DBQuery


DESCRIPTION

A MTK::DBQuery object encapsulates the result of a query against a databsae. It is intended to be database-independent.

$dbq = new MTk::DBQuery($query, $vars, $rows)

DBQuery constructor, intended to be called from the layer-1 database interface. $vars is a ref to an array of column names for the query result. $rows is a ref to an array of array-refs representing the result of the query. $query is the text of the query itself.

$query->n_rows()

Returns the number of rows in the query result.

$val = $query->item($row_idx, $col_id)

Retrieve a specific item from the query. $row_idx is the index of the row from which to retrieve the value. $col_id is the column identifier for the item. The column identifier can be either a number, in which case it is treated as a column index, or a string, in which case it is treated as the name of a column.

$row = $query->row_list($row_idx)

Return the values in row $row_idx. Return value is a reference to an array.

$row = $query->row_hash($row_idx)

Return the values in row $row_idx. Return value is a reference to a hash whose keys are column names.

$row_lists = $query->row_lists()

Return all rows. The return value is a reference to an array of rows. Each row in that array is itself a reference to an array of column values.

$row_hashes = $query->row_hashes()

Return all rows. The return value is a reference to an array of rows. Each row in that array is a reference to a hash whose key is the column name.