interface IFetchStrategy (View source)

This interface defines the strategy for fetching data from a database.

Implementations of this interface should provide specific methods for retrieving data according to the defined strategy.

Methods

string
getResourceId(mixed $resource)

Gets a unique identifier for the given resource.

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

Details

string getResourceId(mixed $resource)

Gets a unique identifier for the given resource.

Parameters

mixed $resource

The resource to get the identifier for It can be of type resource, object, or array.

Return Value

string

A unique identifier for the resource. If the resource is a resource type, it returns its string representation. If it's an object, it returns the object's hash. If it's an array, it returns the MD5 hash of the serialized array. Returns 'null' if the resource type is not recognized.

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