Documentation

ResultCacheStatement
in package
implements IteratorAggregate, ResultStatement

Cache statement for SQL results.

A result is saved in multiple cache keys, there is the originally specified cache key which is just pointing to result rows by key. The following things have to be ensured:

  1. lifetime of the original key has to be longer than that of all the individual rows keys
  2. if any one row key is missing the query has to be re-executed.

Also you have to realize that the cache will load the whole result into memory at once to ensure 2. This means that the memory usage for cached results might increase by using this feature.

Interfaces, Classes and Traits

IteratorAggregate
ResultStatement
Interface for the reading part of a prepare statement only.

Table of Contents

$cacheKey  : string
$data  : array<string|int, mixed>
$defaultFetchMode  : int
$emptied  : bool
Did we reach the end of the statement?
$lifetime  : int
$realKey  : string
$resultCache  : Cache
$statement  : Statement
__construct()  : mixed
closeCursor()  : bool
Closes the cursor, enabling the statement to be executed again.
columnCount()  : int
Returns the number of columns in the result set
fetch()  : mixed
Returns the next row of a result set.
fetchAll()  : array<string|int, mixed>
Returns an array containing all of the result set rows.
fetchColumn()  : string|bool
Returns a single column from the next row of a result set or FALSE if there are no more rows.
getIterator()  : mixed
{@inheritdoc}
rowCount()  : int
Returns the number of rows affected by the last DELETE, INSERT, or UPDATE statement executed by the corresponding object.
setFetchMode()  : bool
Sets the fetch mode to use while iterating this statement.

Properties

Methods

__construct()

public __construct(Statement $stmt, Cache $resultCache, string $cacheKey, string $realKey, int $lifetime) : mixed
Parameters
$stmt : Statement
$resultCache : Cache
$cacheKey : string
$realKey : string
$lifetime : int
Return values
mixed

closeCursor()

Closes the cursor, enabling the statement to be executed again.

public closeCursor() : bool
Return values
bool

TRUE on success or FALSE on failure.

columnCount()

Returns the number of columns in the result set

public columnCount() : int
Return values
int

The number of columns in the result set represented by the PDOStatement object. If there is no result set, this method should return 0.

fetch()

Returns the next row of a result set.

public fetch([mixed $fetchMode = null ]) : mixed
Parameters
$fetchMode : mixed = null

Controls how the next row will be returned to the caller. The value must be one of the PDO::FETCH_* constants, defaulting to PDO::FETCH_BOTH.

Return values
mixed

The return value of this method on success depends on the fetch mode. In all cases, FALSE is returned on failure.

fetchAll()

Returns an array containing all of the result set rows.

public fetchAll([mixed $fetchMode = null ]) : array<string|int, mixed>
Parameters
$fetchMode : mixed = null

Controls how the next row will be returned to the caller. The value must be one of the PDO::FETCH_* constants, defaulting to PDO::FETCH_BOTH.

Return values
array<string|int, mixed>

fetchColumn()

Returns a single column from the next row of a result set or FALSE if there are no more rows.

public fetchColumn(mixed $columnIndex) : string|bool
Parameters
$columnIndex : mixed

0-indexed number of the column you wish to retrieve from the row. If no value is supplied, PDOStatement->fetchColumn() fetches the first column.

Return values
string|bool

A single column in the next row of a result set, or FALSE if there are no more rows.

rowCount()

Returns the number of rows affected by the last DELETE, INSERT, or UPDATE statement executed by the corresponding object.

public rowCount() : int

If the last SQL statement executed by the associated Statement object was a SELECT statement, some databases may return the number of rows returned by that statement. However, this behaviour is not guaranteed for all databases and should not be relied on for portable applications.

Return values
int

The number of rows.

setFetchMode()

Sets the fetch mode to use while iterating this statement.

public setFetchMode(mixed $fetchMode[, mixed $arg2 = null ][, mixed $arg3 = null ]) : bool
Parameters
$fetchMode : mixed

The fetch mode must be one of the PDO::FETCH_* constants.

$arg2 : mixed = null
$arg3 : mixed = null
Return values
bool

Search results