Class DB_result

Description

This class implements a wrapper for a DB result set

A new instance of this class will be returned by the DB implementation after processing a query that returns data.

Located in /DB.php (line 916)


	
			
Variable Summary
boolean $autofree
object $dbh
integer $fetchmode
integer $limit_count
integer $limit_from
array $parameters
string $query
resource $result
integer $row_counter
resource $statement
Method Summary
void DB_result (object &$dbh, resource $result, [array $options = array()])
mixed fetchInto (array &$arr, [int $fetchmode = DB_FETCHMODE_DEFAULT], [int $rownum = null])
mixed &fetchRow ([int $fetchmode = DB_FETCHMODE_DEFAULT], [int $rownum = null])
bool free ()
string getQuery ()
integer getRowCounter ()
bool nextResult ()
int numCols ()
int numRows ()
void setOption (string $key, [mixed $value = null])
void tableInfo ([ $mode = null])
Variables
boolean $autofree (line 925)

Should results be freed automatically when there are no more rows?

  • see: DB_common::$options
object $dbh (line 931)

A reference to the DB_<driver> object

integer $fetchmode (line 938)

The current default fetch mode

  • see: DB_common::$fetchmode
string $fetchmode_object_class (line 947)

The name of the class into which results should be fetched when DB_FETCHMODE_OBJECT is in effect

  • see: DB_common::$fetchmode_object_class
integer $limit_count = null (line 953)

The number of rows to fetch from a limit query

integer $limit_from = null (line 959)

The row to start fetching from in limit queries

array $parameters (line 966)

The execute parameters that created this result

  • since: Property available since Release 1.7.0
string $query (line 976)

The query string that created this result

Copied here incase it changes in $dbh, which is referenced

  • since: Property available since Release 1.7.0
resource $result (line 982)

The query result resource id created by PHP

integer $row_counter = null (line 988)

The present row being dealt with

resource $statement (line 1005)

The prepared statement resource id created by PHP in $dbh

This resource is only available when the result set was created using a driver's native execute() method, not PEAR DB's emulated one.

Copied here incase it changes in $dbh, which is referenced

}

  • since: Property available since Release 1.7.0
Methods
Constructor DB_result (line 1020)

This constructor sets the object's properties

void DB_result (object &$dbh, resource $result, [array $options = array()])
  • object &$dbh: the DB object reference
  • resource $result: the result resource id
  • array $options: an associative array with result options
fetchInto (line 1166)

Fetch a row of data into an array which is passed by reference

The type of array returned can be controlled either by setting this method's $fetchmode parameter or by changing the default fetch mode setFetchMode() before calling this method.

There are two options for standardizing the information returned from databases, ensuring their values are consistent when changing DBMS's. These portability options can be turned on when creating a new DB object or by using setOption().

  • DB_PORTABILITY_LOWERCASE convert names of fields to lower case
  • DB_PORTABILITY_RTRIM right trim the data

  • return: DB_OK if a row is processed, NULL when the end of the result set is reached or a DB_Error object on failure
  • see: DB_common::setOption(), DB_common::setFetchMode()
mixed fetchInto (array &$arr, [int $fetchmode = DB_FETCHMODE_DEFAULT], [int $rownum = null])
  • array &$arr: the variable where the data should be placed
  • int $fetchmode: the constant indicating how to format the data
  • int $rownum: the row number to fetch (index starts at 0)
fetchRow (line 1084)

Fetch a row of data and return it by reference into an array

The type of array returned can be controlled either by setting this method's $fetchmode parameter or by changing the default fetch mode setFetchMode() before calling this method.

There are two options for standardizing the information returned from databases, ensuring their values are consistent when changing DBMS's. These portability options can be turned on when creating a new DB object or by using setOption().

  • DB_PORTABILITY_LOWERCASE convert names of fields to lower case
  • DB_PORTABILITY_RTRIM right trim the data

  • return: an array or object containing the row's data, NULL when the end of the result set is reached or a DB_Error object on failure.
  • see: DB_common::setOption(), DB_common::setFetchMode()
mixed &fetchRow ([int $fetchmode = DB_FETCHMODE_DEFAULT], [int $rownum = null])
  • int $fetchmode: the constant indicating how to format the data
  • int $rownum: the row number to fetch (index starts at 0)
free (line 1284)

Frees the resources allocated for this result set

  • return: true on success. A DB_Error object on failure.
bool free ()
getQuery (line 1320)

Determine the query string that created this result

  • return: the query string
  • since: Method available since Release 1.7.0
string getQuery ()
getRowCounter (line 1333)

Tells which row number is currently being processed

  • return: the current row being looked at. Starts at 1.
integer getRowCounter ()
nextResult (line 1271)

Get the next result if a batch of queries was executed

  • return: true if a new result is available or false if not
bool nextResult ()
numCols (line 1227)

Get the the number of columns in a result set

  • return: the number of columns. A DB_Error object on failure.
int numCols ()
numRows (line 1240)

Get the number of rows in a result set

  • return: the number of rows. A DB_Error object on failure.
int numRows ()
setOption (line 1043)

Set options for the DB_result object

void setOption (string $key, [mixed $value = null])
  • string $key: the option to set
  • mixed $value: the value to set the option to
tableInfo (line 1302)
  • deprecated: Method deprecated some time before Release 1.2
  • see: DB_common::tableInfo()
void tableInfo ([ $mode = null])
  • $mode

Documentation generated on Wed, 28 Mar 2007 09:54:11 -0600 by phpDocumentor 1.3.1