class FetchStrategy implements IFetchStrategy (View source)

Traits

The GenericDatabase\Helpers\Types\Specials\Resources trait provides methods for working with resources.

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

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

string
cacheResource(mixed $resource)

Caches the results from a statement for future use

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

string cacheResource(mixed $resource)

Caches the results from a statement for future use

Parameters

mixed $resource

The statement to cache results from

Return Value

string

The statement identifier