Show:

Db_Result Class

Module: Db

This class lets you use Db results from Db queries

Constructor

Db_Result

(
  • $stmt
  • $query
)

Parameters:

  • $stmt PDOStatement | Array

    The PDO statement object that this result uses Can also be an array of PDO statements, in which case this was the result of an aggregated query.

  • $query Db_Query_Interface

    The query that was run to produce this result

Methods

__call

(
  • $name
  • $arguments
)

Forwards all other calls to the PDOStatement object

Parameters:

  • $name String

    The function name

  • $arguments Array

    The arguments

__toMarkup

() String

Dumps the result as an HTML table. Side effect, though: can't fetch anymore until the cursor is closed.

Returns:

String:

__toString

() String

Dumps the result as a table in text mode Side effect, though: can't fetch anymore until the cursor is closed.

Returns:

String:

fetchAll

() Array

Fetches an array of database rows matching the query. The query is executed and fetchAll() is called on the result.

See PDO documentation

Returns:

Array:

fetchDbRow

(
  • [$class_name=null]
  • [$fields_prefix='']
)
Db_Row | Boolean

Fetches one Db_Row object (possibly extended). You can pass a prefix to strip from the field names. It will also filter the result.

Parameters:

  • [$class_name=null] String optional

    The name of the class to instantiate and fill objects from. Must extend Db_Row. Defaults to $this->query->className

  • [$fields_prefix=''] String optional

    This is the prefix, if any, to strip out when fetching the rows.

Returns:

Db_Row | Boolean:

Returns false if no row, otherwise returns an object of type $class_name

fetchDbRows

(
  • [$class_name=null]
  • [$fields_prefix='']
  • [$by_field=null]
)
Array

Fetches an array of Db_Row objects (possibly extended). You can pass a prefix to strip from the field names. It will also filter the result.

Parameters:

  • [$class_name=null] String optional

    The name of the class to instantiate and fill objects from. Must extend Db_Row. Defaults to $this->query->className

  • [$fields_prefix=''] String optional

    This is the prefix, if any, to strip out when fetching the rows.

  • [$by_field=null] String optional

    A field name to index the array by. If the field's value is NULL in a given row, that row is just appended in the usual way to the array.

Returns:

Array:

Properties

$query

Db_Query_Mysql

The query that was run to produce this result

$stmts

Array

An array of PDO statements if passed to the constructor

stmt

PDOStatement

The PDO statement object that this result uses