Flourish PHP Unframework

fResult

class, implements Iterator , v1.0.0b13

Representation of a result from a query against the fDatabase class

Changes:
1.0.0b12Added a workaround for iconv having issues in MAMP 1.9.4+ 7/26/11
1.0.0b12Fixed MSSQL to have a properly reset row array, added silenceNotices(), fixed pdo_dblib on Windows when using the Microsoft DBLib driver 5/9/11
1.0.0b11Backwards Compatibility Break - removed ODBC support 7/31/10
1.0.0b10Added IBM DB2 support 4/13/10
1.0.0b9Added support for prepared statements 3/2/10
1.0.0b8Fixed a bug with decoding MSSQL national column when using an ODBC connection 9/18/09
1.0.0b7Added the method unescape(), changed tossIfNoRows() to return the object for chaining 8/12/09
1.0.0b6Fixed a bug where fetchAllRows() would throw a fNoRowsException 6/30/09
1.0.0b5Added the method asObjects() to allow for returning objects instead of associative arrays 6/23/09
1.0.0b4Fixed a bug with not properly converting SQL Server text to UTF-8 6/18/09
1.0.0b3Added support for Oracle, various bug fixes 5/4/09
1.0.0b2Updated for new fCore API 2/16/09
1.0.0bThe initial implementation 9/25/07

Static Methods

::compose() protected

Composes text using fText if loaded

Signature

string compose( string $message, mixed $component [, ... ] )

Parameters

string $message The message to compose
mixed $component [, ... ] A string or number to insert into the message

Returns

The composed and possible translated message

::silenceNotices() public

Turns off notices about broken database extensions much as the MSSQL DBLib driver

Signature

void silenceNotices( )

Methods

->__construct() internal public

Please note: this method is public, however it is primarily intended for internal use by Flourish and will normally not be useful in site/application code

Configures the result set

Signature

fResult __construct( fDatabase $database, string $character_set=NULL )

Parameters

fDatabase $database The database object this result set was created from
string $character_set MSSQL only: the character set to transcode from since MSSQL doesn't do UTF-8

->__destruct() internal public

Please note: this method is public, however it is primarily intended for internal use by Flourish and will normally not be useful in site/application code

Frees up the result object to save memory

Signature

void __destruct( )

->__get() internal public

Please note: this method is public, however it is primarily intended for internal use by Flourish and will normally not be useful in site/application code

All requests that hit this method should be requests for callbacks

Signature

callback __get( string $method )

Parameters

string $method The method to create a callback for

Returns

The callback for the method requested

->asObjects() public

Sets the object to return rows as objects instead of associative arrays (the default)

Signature

fResult asObjects( )

Returns

The result object, to allow for method chaining

->countAffectedRows() public

Returns the number of rows affected by the query

Signature

integer countAffectedRows( )

Returns

The number of rows affected by the query

->countReturnedRows() public

Returns the number of rows returned by the query

Signature

integer countReturnedRows( )

Returns

The number of rows returned by the query

->current() internal public implements Iterator

Please note: this method is public, however it is primarily intended for internal use by Flourish and will normally not be useful in site/application code

Returns the current row in the result set (required by iterator interface)

Signature

array|stdClass current( )

Returns

The current row

Throws

fNoRemainingException
When there are no remaining rows in the result
fNoRowsException
When the query did not return any rows

->fetchAllRows() public

Returns all of the rows from the result set

Signature

array fetchAllRows( )

Returns

The array of rows

->fetchRow() public

Returns the row next row in the result set (where the pointer is currently assigned to)

Signature

array|stdClass fetchRow( )

Returns

The next row in the result

Throws

fNoRemainingException
When there are no rows left in the result
fNoRowsException
When the query did not return any rows

->fetchScalar() public

Wraps around fetchRow() and returns the first field from the row instead of the whole row

Signature

string|number|boolean fetchScalar( )

Returns

The first scalar value from fetchRow()

Throws

fNoRemainingException
When there are no rows left in the result
fNoRowsException
When the query did not return any rows

->getAutoIncrementedValue() public

Returns the last auto incremented value for this database connection. This may or may not be from the current query.

Signature

integer getAutoIncrementedValue( )

Returns

The auto incremented value

->getResult() internal public

Please note: this method is public, however it is primarily intended for internal use by Flourish and will normally not be useful in site/application code

Returns the result

Signature

mixed getResult( )

Returns

The result of the query

->getSQL() public

Returns the SQL used in the query

Signature

string getSQL( )

Returns

The SQL used in the query

->getUntranslatedSQL() public

Returns the SQL as it was before translation

Signature

string getUntranslatedSQL( )

Returns

The SQL from before translation

->key() internal public implements Iterator

Please note: this method is public, however it is primarily intended for internal use by Flourish and will normally not be useful in site/application code

Returns the current row number (required by iterator interface)

Signature

integer key( )

Returns

The current row number

Throws

fNoRemainingException
When there are no remaining rows in the result
fNoRowsException
When the query did not return any rows

->next() internal public implements Iterator

Please note: this method is public, however it is primarily intended for internal use by Flourish and will normally not be useful in site/application code

Advances to the next row in the result (required by iterator interface)

Signature

void next( )

Throws

fNoRemainingException
When there are no remaining rows in the result
fNoRowsException
When the query did not return any rows

->rewind() internal public implements Iterator

Please note: this method is public, however it is primarily intended for internal use by Flourish and will normally not be useful in site/application code

Rewinds the query (required by iterator interface)

Signature

void rewind( )

->seek() public

Seeks to the specified zero-based row for the specified SQL query

Signature

void seek( integer $row )

Parameters

integer $row The row number to seek to (zero-based)

Throws

fNoRowsException
When the query did not return any rows

->setAffectedRows() internal public

Please note: this method is public, however it is primarily intended for internal use by Flourish and will normally not be useful in site/application code

Sets the number of affected rows

Signature

void setAffectedRows( integer $affected_rows )

Parameters

integer $affected_rows The number of affected rows

->setAutoIncrementedValue() internal public

Please note: this method is public, however it is primarily intended for internal use by Flourish and will normally not be useful in site/application code

Sets the auto incremented value

Signature

void setAutoIncrementedValue( integer $auto_incremented_value )

Parameters

integer $auto_incremented_value The auto incremented value

->setResult() internal public

Please note: this method is public, however it is primarily intended for internal use by Flourish and will normally not be useful in site/application code

Sets the result from the query

Signature

void setResult( mixed $result )

Parameters

mixed $result The result from the query

->setReturnedRows() internal public

Please note: this method is public, however it is primarily intended for internal use by Flourish and will normally not be useful in site/application code

Sets the number of rows returned

Signature

void setReturnedRows( integer $returned_rows )

Parameters

integer $returned_rows The number of rows returned

->setSQL() internal public

Please note: this method is public, however it is primarily intended for internal use by Flourish and will normally not be useful in site/application code

Sets the SQL used in the query

Signature

void setSQL( string $sql )

Parameters

string $sql The SQL used in the query

->setUntranslatedSQL() internal public

Please note: this method is public, however it is primarily intended for internal use by Flourish and will normally not be useful in site/application code

Sets the SQL from before translation

Signature

void setUntranslatedSQL( string $untranslated_sql )

Parameters

string $untranslated_sql The SQL from before translation

->tossIfNoRows() public

Throws an fNoResultException if the query did not return any rows

Signature

fResult tossIfNoRows( string $message=NULL )

Parameters

string $message The message to use for the exception if there are no rows in this result set

Returns

The result object, to allow for method chaining

Throws

fNoRowsException
When the query did not return any rows

->unescape() public

Sets the result object to unescape all values as they are retrieved from the object

The data types should be from the list of types supported by fDatabase::unescape().

Signature

fResult unescape( array $column_data_type_map )

Parameters

array $column_data_type_map An associative array with column names as the keys and the data types as the values

Returns

The result object, to allow for method chaining

->valid() public implements Iterator

Returns if the query has any rows left

Signature

boolean valid( )

Returns

If the iterator is still valid