trait FetchCache (View source)

Provides caching functionality for fetch operations, allowing results to be stored and retrieved efficiently. It maintains the state of cached results, their positions, and handles resetting fetch positions when necessary.

Methods:

  • cacheResults(mixed $resource): array: Caches the results from a statement for future use.
  • handleFetchReset(mixed $resource): void: Handles resetting the fetch position and caching results if not already cached.
  • cacheResource(mixed $resource): array: Abstract method to be implemented in the class using this trait.

Fields:

  • $cachedResults: Stores the cached results of fetch operations.
  • $positions: Keeps track of the positions of fetched data.
  • $lastFetchAll: Stores the results of the last fetch all operation.

Methods

array
cacheResults(mixed $resource)

Caches the results from a statement for future use

void
handleFetchReset(mixed $resource)

Handles resetting the fetch position and caching results if not already cached

string
cacheResource(mixed $resource)

Método abstrato para ser implementado na classe que usa a trait

Details

array cacheResults(mixed $resource)

Caches the results from a statement for future use

Parameters

mixed $resource

The statement to cache results from

Return Value

array

An associative array containing the cached results, the current position and the statement identifier

void handleFetchReset(mixed $resource)

Handles resetting the fetch position and caching results if not already cached

Parameters

mixed $resource

The statement resource

Return Value

void

abstract protected string cacheResource(mixed $resource)

Método abstrato para ser implementado na classe que usa a trait

Parameters

mixed $resource

Return Value

string