DatabaseProvider methods

clearCacheQuery( cacheKeyNamingOptions, overrideCacheProviderName )

Clears the cache for the query identified by the given cacheKeyNamingOptions

  • cacheKeyNamingOptions An optional hash array with the cache key naming options. Cache::buildCacheKey

  • overrideCacheProviderName If specified, the cache provider with this name will be used instead of the one in the Database configuration key cacheProviderName.

Returns: True if the cache could be cleared successfully, false otherwise.

execute( prepareResult, parameters )

Executes a previously prepared query with the given parameters.

  • prepareResult The prepare result as returned by the DatabaseProvider::prepare method.

  • parameters A hash array with the variables to be applied to the prepared result, in the same order as they are stated in the original SQL statement, where each item in the array is a hash array with the following keys:

prepare( sql )

Prepares a query so it can be later executed as a prepared query with the DatabaseProvider::execute method.

  • sql The SQL statement to prepare to be queried to the database, where all the variables are replaced by question marks.

Returns: A hash array with the following keys:

  • sql The passed SQL statement.

  • statement A provider-specific statement object if the query has been prepared correctly, false otherwise.

prepareAndExecute( sql, parameters, setup )

Prepares and executes a prepared query

  • sql The prepared SQL statement.

  • parameters A hash array with the variables to be applied to the prepared SQL statement, in the same order as they are stated in the SQL, with the same structure as in the DatabaseProvider::execute method.

  • setup Optional hash array with options, same specification as DatabaseResult::$setup

Returns: A DatabaseResult object if the query was executed correctly, false otherwise.

prepareAndExecuteCache( sql, parameters, cacheTtl, cacheKeyNamingOptions, overrideCacheProviderName, isStoreInCacheWhenNoResults, setup )

Prepares and executes a prepared query implementing a caching mechanism. If the query results are stored in the cache, it retrieves them. If not in cache, it performs the query and stores the results in cache.

  • sql The SQL statement.

  • parameters A hash array with the variables to be applied to the prepared SQL statement, in the same order as they are stated in the SQL, with the same structure as in the DatabaseProvider::execute method.

  • cacheTtl The TTL for the cache results. If not specified, the Database configuration key cacheDefaultTtl is used.

  • cacheKeyNamingOptions An optional hash array with the cache key naming options. Cache::buildCacheKey

  • overrideCacheProviderName If specified, the cache provider with this name will be used instead of the one in the Database configuration key cacheProviderName.

  • isStoreInCacheWhenNoResults Whether to store results in the cache when the query returned no rows or not.

  • setup Optional setup keys, as specified in DatabaseResult::$setup

query( query, setup )

Performs a query to the database.

  • query The SQL query string

  • setup An optional hash array with setup options.

queryCache( sql, cacheTtl, cacheKeyNamingOptions, overrideCacheProviderName, isStoreInCacheWhenNoResults, setup )

Performs a query to the database implementing a caching mechanism. If the query results are stored in the cache, it retrieves them. If not in cache, it performs the query and stores the results in cache.

  • query The SQL statement.

  • cacheTtl The TTL for the cache results. If not specified, the Database configuration key cacheDefaultTtl is used.

  • cacheKeyNamingOptions An optional hash array with the cache key naming options. Cache::buildCacheKey

  • overrideCacheProviderName If specified, the cache provider with this name will be used instead of the one in the Database configuration key cacheProviderName.

  • isStoreInCacheWhenNoResults Whether to store results in the cache when the query returned no rows or not.

  • setup Optional setup keys, as specified in DatabaseResult::$setup.

Returns: A provider-specific DatabaseResult object if the query was executed or retrieved from cache successfully, false otherwise.

Last updated