Cherrycake
ExamplesGithub
version 2.x alpha
version 2.x alpha
  • Introduction
  • Status
  • Changelog
  • Migration
  • Architecture
    • Basics
    • Modules
    • Classes
    • Lifecycle
      • Deep lifecycle
    • Performance
    • Security
    • Patterns
      • Files structure
    • Items
    • Server requirements
  • Guide
    • Getting started
      • Skeleton start
      • Docker start
    • Modules guide
    • Classes guide
    • Actions guide
      • Complex actions
      • Variable path components
      • Accept GET or POST parameters
      • Getting the URL of an action
      • Cached actions
      • Brute force attacks
    • Patterns guide
      • Passing variables to a pattern
      • Nested patterns
      • Cached patterns
    • Cache guide
      • Time To Live
      • Using cache
      • Lists
      • Queues
      • Pools
    • Database guide
      • Basic queries
      • Prepared queries
      • Cached queries
      • Cache key naming
      • Removing queries from cache
    • Items guide
      • Item cache
      • Item lists
      • Items custom filters
      • Items custom ordering
      • Mixing filters and ordering
      • Items with relationships
      • Items cache
    • HtmlDocument guide
    • Css and Javascript guide
      • Modules injecting CSS and JavaScript
    • Session guide
    • Login guide
      • Creating a complete login workflow
    • Locale guide
      • Multilingual texts
      • Domain based site localization
    • Log guide
      • Loading Log events from the database
    • Stats guide
      • Stats events with additional dimensions
      • Loading Stats events from the database
    • Janitor guide
      • Janitor tasks configuration files
    • Command line interface
    • Debugging
  • Reference
    • Core modules
      • Actions
        • Actions methods
      • Browser
      • Cache
        • Cache methods
      • Css
        • Css methods
      • Database
      • Email
      • Errors
      • HtmlDocument
        • HtmlDocument methods
      • ItemAdmin
      • Janitor
        • Janitor methods
      • Javascript
        • Javascript methods
      • Locale
        • Locale methods
      • Log
        • Log methods
      • Login
        • Login methods
      • Output
        • Output methods
      • Patterns
        • Patterns methods
      • Security
        • Security methods
      • Session
        • Session methods
      • Stats
        • Stats methods
      • SystemLog
      • TableAdmin
      • Translation
      • Validate
    • Core classes
      • Action
        • Action methods
        • Action properties
      • AjaxResponseJson
      • BasicObject
        • BasicObject methods
      • CacheProvider
        • CacheProvider methods
      • Color
      • DatabaseProvider
        • DatabaseProvider methods
      • DatabaseResult
        • DatabaseResult methods
        • DatabaseResult properties
      • DatabaseRow
      • Engine
        • Engine methods
        • Engine properties
      • Gradient
      • Item
        • Item methods
        • Item properties
      • Items
        • Items methods
        • Items properties
      • Image
      • JanitorTask
        • JanitorTask methods
        • JanitorTask properties
      • LogEvent
        • LogEvent methods
        • LogEvent Properties
      • LogEvents
        • LogEvents methods
      • Module
        • Module methods
        • Module properties
      • Response
      • Request
        • Request methods
      • RequestParameter
        • RequestParameter methods
      • RequestPathComponent
        • RequestPathComponent methods
      • Result
      • StatsEvent
        • StatsEvent properties
      • StatsEvents
        • StatsEvents methods
      • SystemLogEvent
        • SystemLogEvent methods
        • SystemLogEvent properties
      • SystemLogEvents
        • SystemLogEvents methods
  • Code conventions
  • License
  • Extras
Powered by GitBook
On this page
  • clearCacheQuery( cacheKeyNamingOptions, overrideCacheProviderName )
  • execute( prepareResult, parameters )
  • prepare( sql )
  • prepareAndExecute( sql, parameters, setup )
  • prepareAndExecuteCache( sql, parameters, cacheTtl, cacheKeyNamingOptions, overrideCacheProviderName, isStoreInCacheWhenNoResults, setup )
  • query( query, setup )
  • queryCache( sql, cacheTtl, cacheKeyNamingOptions, overrideCacheProviderName, isStoreInCacheWhenNoResults, setup )

Was this helpful?

  1. Reference
  2. Core classes
  3. DatabaseProvider

DatabaseProvider methods

PreviousDatabaseProviderNextDatabaseResult

Last updated 5 years ago

Was this helpful?

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.

  • 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 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:

    • type One of the available , like DATABASE_FIELD_TYPE_INTEGER

    • value The value of the variable.

prepare( sql )

Prepares a query so it can be later executed as a prepared query with the 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.

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.

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

  • 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.

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.

  • 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.

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 method.

setup Optional hash array with options, same specification as

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

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 method.

cacheKeyNamingOptions An optional hash array with the cache key naming options.

setup Optional setup keys, as specified in

cacheKeyNamingOptions An optional hash array with the cache key naming options.

setup Optional setup keys, as specified in .

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

DatabaseResult
DatabaseResult
DatabaseProvider::execute
DatabaseProvider::execute
DatabaseProvider::prepare
DatabaseProvider::execute
DatabaseResult::$setup
DatabaseResult::$setup
DatabaseResult::$setup
Cache::buildCacheKey
Cache::buildCacheKey
Cache::buildCacheKey
database field type constants