Documentation

MySQL extends AbstractDatabase
in package
implements DatabaseInterface

A MySQL Data Object

Table of Contents

Interfaces

DatabaseInterface

Properties

$cache_ttl  : int
$debug  : bool
$enable_cache  : bool
$query_counter  : int
$unique_queries  : array<string|int, mixed>
$conf  : TiqConfig
$db_name  : string
$dsn  : string
$error_message  : string
Base error message, this belongs in com_think's configuration class
$host  : string
$password  : string
$port  : string|null
$query_cache  : array<string|int, mixed>
$user_name  : string
$DataSourceName  : string

Methods

__construct()  : mixed
Parses Config info and sets some default options.
clearCache()  : void
Clear the query cache completely or for a specific query
DataSourceName()  : string
Gets back the database source name.
errorMessage()  : string
Returns an error message that should be actionable. The information in the error message comes from the database.
run()  : PDOStatement|false
Compresses a basic query down into one function.
generateCacheKey()  : string
Generate a cache key for a query and its arguments
parseConfig()  : void
Breaks down the TiqConfig Object.
profileQuery()  : void
Profile a query for debugging purposes

Properties

$cache_ttl

public int $cache_ttl = 300
  • Time-to-live for cached queries in seconds

$enable_cache

public bool $enable_cache = true
  • Whether query caching is enabled

$query_counter

public int $query_counter = 0
  • Counts the number of queries run

$unique_queries

public array<string|int, mixed> $unique_queries = []
  • Tracks statistics about unique queries

$error_message

Base error message, this belongs in com_think's configuration class

protected string $error_message = 'An issue occurred, please contact ThinkIQ for Support and enable debugging'
Tags
since

version 3.3.0

$query_cache

protected array<string|int, mixed> $query_cache = []
  • Caches query results for repeated queries

$DataSourceName

private string $DataSourceName = "mysql"

Methods

__construct()

Parses Config info and sets some default options.

public __construct(TiqConfig $conf[, array<string|int, mixed> $options = [] ][, string $DataSourceName = "mysql" ]) : mixed
Parameters
$conf : TiqConfig
  • Contains sensitive configuration data.
$options : array<string|int, mixed> = []
  • PDO class attributes.
$DataSourceName : string = "mysql"
  • What type of data source are we connecting too, example: mysql or pgsql.

clearCache()

Clear the query cache completely or for a specific query

public clearCache([string|null $sql = null ][, mixed|null $args = null ]) : void
Parameters
$sql : string|null = null
  • The SQL query to clear, or null to clear all
$args : mixed|null = null
  • The query arguments (if clearing a specific query)

DataSourceName()

Gets back the database source name.

public DataSourceName() : string
Return values
string

errorMessage()

Returns an error message that should be actionable. The information in the error message comes from the database.

public errorMessage(PDOException $exception) : string
Parameters
$exception : PDOException
Tags
since

version 3.3.0

Return values
string

run()

Compresses a basic query down into one function.

public run(string $sql[, mixed $args = null ][, bool $use_cache = false ]) : PDOStatement|false
Parameters
$sql : string
  • sql query.
$args : mixed = null
  • arguments to be used in the sql string.
$use_cache : bool = false
  • Allows caching of a query and args, if that same query is made again, we return the cached result
Tags
throws
Exception
Return values
PDOStatement|false

generateCacheKey()

Generate a cache key for a query and its arguments

protected generateCacheKey(string $sql, mixed $args) : string
Parameters
$sql : string
  • The SQL query
$args : mixed
  • The query arguments
Return values
string
  • A unique cache key

parseConfig()

Breaks down the TiqConfig Object.

protected parseConfig(TiqConfig $conf) : void
Parameters
$conf : TiqConfig
  • Contains sensitive configuration data.

profileQuery()

Profile a query for debugging purposes

protected profileQuery(string $sql, float $execution_time, bool $cached) : void
Parameters
$sql : string
  • The SQL query
$execution_time : float
  • The execution time in seconds
$cached : bool
  • Whether this was a cache hit

        
On this page

Search results