CDB
in package
implements
IDBMS
Main class for DB interaction and caching.
It implements the IDBMS interface and relies on it for all constants.
Table of Contents
Interfaces
- IDBMS
- Interface for a generic Database Management System.
Properties
- $all_modules : array<string|int, mixed>
- $all_tables : array<string|int, mixed>
- $cache : ICache|null
- $connection_manager : IConnectionManager|null
- $dbms : IDBMS
- $dbms_type : string
- $last_id : int
- $logger : ILogger
- $static_connection_manager : IConnectionManager|null
- $table : string
Methods
- __construct() : mixed
- Constructor
- __destruct() : mixed
- Destructor
- BeginTransaction() : void
- Starts a DB transaction.
- Commit() : void
- Commits the current transaction.
- Connect() : IConnectionManager
- Static method to connect to database
- ConnectionManager() : IConnectionManager
- Gets the connection manager instance.
- ConvertDBType2BindType() : string
- Converts a generic DB data type into a driver-specific bind type.
- Decrypt() : string
- Returns the DB instruction to decrypt a value.
- DeleteRecord() : bool
- Delete records from a DB table
- Disconnect() : void
- Releases the resource to connect to the DB
- DisconnectAll() : void
- Releases all the resources of the previously opened DBs
- Encrypt() : string
- Returns the DB instruction to encrypt a value.
- Execute() : void
- Executes a previously prepared statement.
- ExistsTable() : bool
- Checks if a table exists in the database.
- ExistsTableColumns() : bool
- Checks if a list of columns exists in a table.
- GetAffectedRows() : int
- Returns how many rows were affected by the last operation performed.
- GetAllModules() : array<string|int, mixed>
- Returns a list of all modules, using cache.
- GetAllTables() : array<string|int, mixed>
- Returns a list of all tables, using cache.
- GetArrayByName() : array<string|int, mixed>|null
- Fetches a result set into a key-value array, using array_column for optimization.
- GetArrayItemOfElements() : array<string|int, mixed>|null
- Given an array of records, returns a new array containing only the values of a specific field.
- GetAttributesFromType() : bool
- Gets field attributes based on a DB data type.
- GetCache() : ICache|null
- Returns the cache object
- GetCachedArrayByName() : array<string|int, mixed>|null
- Fetches a result set into a key-value array, using cache.
- GetCachedDataTable() : void
- Fetches a full result set into an array, using cache.
- GetCachedDataValue() : string|null
- Fetches a single data value from a query, using cache.
- GetCachedFetchAssoc() : array<string|int, mixed>|null
- Fetches an associative array from a query, using cache.
- GetCachedFetchRow() : array<string|int, mixed>|null
- Fetches an associative array from a query, using cache.
- GetCachedIDsArray() : array<string|int, mixed>
- Fetches a single column from a result set into an array, using cache.
- GetColumnNames() : array<string|int, string>|null
- Returns an array containing the names of all columns for the last query executed.
- GetConnectionManager() : IConnectionManager|null
- GetConnectionManager( )
- GetCurrentDate() : string
- Returns the current date.
- GetCurrentDateTime() : string
- Returns the current date and time.
- GetDataTable() : int|null
- Fetches the entire result set of a query into an array.
- GetDataValue() : string|null
- Returns a single value from a query result.
- GetDbmsType() : string
- Get the name of DBMS used
- GetDBResultAssoc() : int
- Returns the driver-specific value for an associative array fetch type.
- GetDBResultBoth() : int
- Returns the driver-specific value for a fetch type that includes both associative and numeric arrays.
- GetDBResultNum() : int
- Returns the driver-specific value for a numeric array fetch type.
- GetDBTable() : string
- Returns the name of the current main table
- GetFetchArray() : array<string|int, mixed>|null
- Fetches a result row as an array (both numeric and associative).
- GetFetchAssoc() : array<string|int, mixed>|null
- Fetches a result row as an associative array.
- GetFetchRow() : array<string|int, mixed>|null
- Fetches a result row as a numeric array.
- GetIDsArray() : array<string|int, mixed>
- Fetches a single column from the last query result into an array.
- GetLastDBErrorNumber() : int
- Gets any error number issued by the DB.
- GetLastDBErrorString() : string
- Gets any error string issued by the DB.
- GetLastID() : int|null
- Returns the ID of the last inserted item
- GetNextID() : int|null
- Returns the next ID from a sequence or similar.
- GetQueryDataTable() : int|null
- Queries the DB and returns the result in a two-dimensional array.
- GetQueryDataValue() : string|null
- Executes a query and fetches a single value.
- GetQueryFetchAssoc() : array<string|int, mixed>|null
- Executes a query and fetches a single row as an associative array.
- GetQueryFetchRow() : array<string|int, mixed>|null
- Executes a query and fetches a single row as an numeric index array.
- GetTableColumnNames() : array<string|int, string>
- Returns an array containing the names of all columns of a table.
- GetTotalColumns() : int|bool
- Returns the number of columns of a previously executed query.
- GetTotalRows() : int|bool
- Reads the total number of rows from a previously executed query.
- InsertRecord() : bool
- Make an entry in the DB
- InsertRecordBatch() : bool
- Insert multiple records in a single batch operation
- LoadAllTables() : void
- Loads the schema of all tables into an array.
- Prepare() : void
- Prepares an SQL statement for execution.
- Query() : bool
- Executes a query on the DB.
- Rollback() : void
- Rolls back the current transaction.
- SetAllModules() : void
- Returns a list of all modules, using cache.
- SetAllTables() : array<string|int, mixed>
- Returns a list of all tables, using cache.
- SetAutoCommit() : void
- Sets the autocommit mode.
- SetDBColumns() : void
- Loads the schema of a table's columns into an array.
- SetDBTable() : void
- Sets the name of the reference table for the instance.
- UpdateRecord() : bool
- Make an update in the DB
- GetCachedData() : mixed
- Retrieves data from the cache.
- GetCacheKey() : string
- Generates a unique cache key from a string.
- InvalidateRelatedCache() : void
- Invalidates the cache for a given table and its related tables.
- SetCachedData() : void
- Stores data in the cache.
- ConvertFetchType() : int
- Converts a generic fetch type constant to the driver-specific value.
- CreateDbmsDriver() : IDBMS
- Internal factory to create the appropriate DBMS driver.
Properties
$all_modules
protected
array<string|int, mixed>
$all_modules
= []
list of all modules with column_list list
$all_tables
protected
array<string|int, mixed>
$all_tables
= []
list of all tables of current DB with column_list list
$cache
protected
ICache|null
$cache
= null
The cache instance
$connection_manager
protected
IConnectionManager|null
$connection_manager
= null
The connection manager instance
$dbms
protected
IDBMS
$dbms
The actual DB driver instance
$dbms_type
protected
string
$dbms_type
= ''
name of DBMS for this connection (mysql, oracle, postgresql)
$last_id
protected
int
$last_id
= 0
The last inserted ID
$logger
protected
ILogger
$logger
= null
the object dedicated to track info/warning/error
$static_connection_manager
protected
static IConnectionManager|null
$static_connection_manager
= null
Static connection manager for backward compatibility
$table
protected
string
$table
= ''
The default table name for operations
Methods
__construct()
Constructor
public
__construct([string $table = '' ][, IConnectionManager|null $connection_manager = null ][, ICache|null $cache = null ][, ILogger|null $logger = null ]) : mixed
Parameters
- $table : string = ''
-
name of the default db table
- $connection_manager : IConnectionManager|null = null
-
Optional connection manager
- $cache : ICache|null = null
-
Optional cache instance
- $logger : ILogger|null = null
-
Optional logger instance
__destruct()
Destructor
public
__destruct() : mixed
BeginTransaction()
Starts a DB transaction.
public
BeginTransaction() : void
Commit()
Commits the current transaction.
public
Commit() : void
Connect()
Static method to connect to database
public
static Connect(string $dbname, string $username, string $pwd[, string|null $type = null ][, string|null $hostname = null ][, int|string|null $port = null ]) : IConnectionManager
Parameters
- $dbname : string
-
name of the database
- $username : string
-
database username
- $pwd : string
-
database password
- $type : string|null = null
-
DBMS type
- $hostname : string|null = null
-
server hostname
- $port : int|string|null = null
-
communication port
Tags
Return values
IConnectionManager —The connection manager instance
ConnectionManager()
Gets the connection manager instance.
public
ConnectionManager() : IConnectionManager
Tags
Return values
IConnectionManager —The connection manager
ConvertDBType2BindType()
Converts a generic DB data type into a driver-specific bind type.
public
ConvertDBType2BindType(string|null $db_type) : string
Parameters
- $db_type : string|null
-
The DB data type.
Return values
string —The corresponding variable type for parameter binding.
Decrypt()
Returns the DB instruction to decrypt a value.
public
Decrypt(string $val[, string $name = '' ]) : string
Parameters
- $val : string
-
value or field name to decrypt
- $name : string = ''
-
alias for the returned field
Return values
string —DB instruction to decrypt $val
DeleteRecord()
Delete records from a DB table
public
DeleteRecord(string|null $table, string $conditions, array<string|int, mixed> $conditions_values, array<string|int, mixed> $types) : bool
Parameters
- $table : string|null
-
name of the table
- $conditions : string
-
of the where clause
- $conditions_values : array<string|int, mixed>
-
values present in the WHERE condition
- $types : array<string|int, mixed>
-
of DB table fields
Return values
bool —result of the operation, true if successful
Disconnect()
Releases the resource to connect to the DB
public
static Disconnect([string|null $dbkey = null ]) : void
Parameters
- $dbkey : string|null = null
-
key of db to disconnect (optional)
DisconnectAll()
Releases all the resources of the previously opened DBs
public
static DisconnectAll() : void
Encrypt()
Returns the DB instruction to encrypt a value.
public
Encrypt(string $val[, string $name = '' ]) : string
Parameters
- $val : string
-
value or field name to be encrypted
- $name : string = ''
-
alias for the returned field
Return values
string —DB instruction to encrypt $val
Execute()
Executes a previously prepared statement.
public
Execute([array<string|int, mixed> $bind_param_values = [] ][, array<string|int, mixed> $bind_param_types = [] ]) : void
Parameters
- $bind_param_values : array<string|int, mixed> = []
- $bind_param_types : array<string|int, mixed> = []
ExistsTable()
Checks if a table exists in the database.
public
ExistsTable(string $table) : bool
Parameters
- $table : string
-
name of the table
Return values
bool —true if it exists, false if it does not
ExistsTableColumns()
Checks if a list of columns exists in a table.
public
ExistsTableColumns(string|null $table, array<string|int, mixed> $names) : bool
Parameters
- $table : string|null
-
name of table
- $names : array<string|int, mixed>
-
list of field names to check
Return values
bool —true if all fields exist
GetAffectedRows()
Returns how many rows were affected by the last operation performed.
public
GetAffectedRows() : int
Return values
int —total of rows affected by the last operation
GetAllModules()
Returns a list of all modules, using cache.
public
GetAllModules() : array<string|int, mixed>
Return values
array<string|int, mixed>GetAllTables()
Returns a list of all tables, using cache.
public
GetAllTables() : array<string|int, mixed>
Return values
array<string|int, mixed> —list of all tables
GetArrayByName()
Fetches a result set into a key-value array, using array_column for optimization.
public
GetArrayByName([string|int $name = 'name' ][, string|null $fieldname_value = null ]) : array<string|int, mixed>|null
Parameters
- $name : string|int = 'name'
-
The column to use as the key.
- $fieldname_value : string|null = null
-
The column to use as the value. If null, the rest of the row is used.
Return values
array<string|int, mixed>|null —The resulting key-value array.
GetArrayItemOfElements()
Given an array of records, returns a new array containing only the values of a specific field.
public
GetArrayItemOfElements(array<string|int, mixed> &$elements, string $fieldname) : array<string|int, mixed>|null
Parameters
- $elements : array<string|int, mixed>
-
The source array of records.
- $fieldname : string
-
The field name to extract.
Return values
array<string|int, mixed>|null —An array containing the extracted values.
GetAttributesFromType()
Gets field attributes based on a DB data type.
public
GetAttributesFromType(string $type, array<string|int, mixed> &$values) : bool
Parameters
- $type : string
-
the db type to check (e.g., INT, VARCHAR)
- $values : array<string|int, mixed>
-
container for the attributes
Return values
bool —true if attributes were found
GetCache()
Returns the cache object
public
GetCache() : ICache|null
Return values
ICache|null —the cache object if exists
GetCachedArrayByName()
Fetches a result set into a key-value array, using cache.
public
GetCachedArrayByName(ISqlComposer $sql[, string|int $name = 'name' ][, string|null $fieldname_value = null ]) : array<string|int, mixed>|null
Parameters
- $sql : ISqlComposer
-
The SQL query object.
- $name : string|int = 'name'
-
The column to use as the key.
- $fieldname_value : string|null = null
-
The column to use as the value.
Return values
array<string|int, mixed>|null —The resulting key-value array.
GetCachedDataTable()
Fetches a full result set into an array, using cache.
public
GetCachedDataTable(mixed &$data, ISqlComposer $sql[, int|null $type = null ][, string|null $with_index = null ]) : void
Parameters
- $data : mixed
-
The array to populate.
- $sql : ISqlComposer
-
The SQL query object.
- $type : int|null = null
-
The generic fetch type (IDBMS::DB_ASSOC, etc.).
- $with_index : string|null = null
-
The field to use as an index for the result array.
GetCachedDataValue()
Fetches a single data value from a query, using cache.
public
GetCachedDataValue(ISqlComposer $sql[, int|string $name_col = '0' ][, int|null $pos_row = null ]) : string|null
Parameters
- $sql : ISqlComposer
-
The SQL query object.
- $name_col : int|string = '0'
-
The column name or index.
- $pos_row : int|null = null
-
The row number.
Return values
string|null —The fetched value or null.
GetCachedFetchAssoc()
Fetches an associative array from a query, using cache.
public
GetCachedFetchAssoc(ISqlComposer $sql[, int|null $pos_row = null ]) : array<string|int, mixed>|null
Parameters
- $sql : ISqlComposer
-
The SQL query object.
- $pos_row : int|null = null
-
The row number to fetch.
Return values
array<string|int, mixed>|null —The fetched row or null.
GetCachedFetchRow()
Fetches an associative array from a query, using cache.
public
GetCachedFetchRow(ISqlComposer $sql[, int|null $pos_row = null ]) : array<string|int, mixed>|null
Parameters
- $sql : ISqlComposer
-
The SQL query object.
- $pos_row : int|null = null
-
The row number to fetch.
Return values
array<string|int, mixed>|null —The fetched row or null.
GetCachedIDsArray()
Fetches a single column from a result set into an array, using cache.
public
GetCachedIDsArray(ISqlComposer $sql[, int|string $item = 0 ][, int|string|null $idx = null ]) : array<string|int, mixed>
Parameters
- $sql : ISqlComposer
-
The SQL query object.
- $item : int|string = 0
-
The column index or name to fetch.
- $idx : int|string|null = null
-
The column index or name to use as the array key.
Return values
array<string|int, mixed> —An array of values.
GetColumnNames()
Returns an array containing the names of all columns for the last query executed.
public
GetColumnNames() : array<string|int, string>|null
Return values
array<string|int, string>|null —the associative array of column names
GetConnectionManager()
GetConnectionManager( )
public
GetConnectionManager() : IConnectionManager|null
Return values
IConnectionManager|null —The Connection Manager
GetCurrentDate()
Returns the current date.
public
static GetCurrentDate() : string
Return values
string —The current date in 'Y-m-d' format.
GetCurrentDateTime()
Returns the current date and time.
public
static GetCurrentDateTime() : string
Return values
string —The current date and time in 'Y-m-d H:i:s' format.
GetDataTable()
Fetches the entire result set of a query into an array.
public
GetDataTable(array<string|int, mixed> &$data[, int|null $type = null ][, string|null $with_index = null ]) : int|null
Parameters
- $data : array<string|int, mixed>
-
array containing the records found
- $type : int|null = null
-
the fetch type (e.g., IDBMS::DB_ASSOC)
- $with_index : string|null = null
-
field name to use as the index of the main array
Return values
int|null —the total of records found or null on error
GetDataValue()
Returns a single value from a query result.
public
GetDataValue([int|string $name_col = '0' ][, int|null $pos_row = null ]) : string|null
Parameters
- $name_col : int|string = '0'
-
column name or numeric index
- $pos_row : int|null = null
-
position of the row
Return values
string|null —value of the indicated cell, or null if it does not exist
GetDbmsType()
Get the name of DBMS used
public
GetDbmsType() : string
Return values
string —the name of DBMS used. i.e.: mysql, oracle, postgresql (the convention is all in lowercase)
GetDBResultAssoc()
Returns the driver-specific value for an associative array fetch type.
public
GetDBResultAssoc() : int
Return values
intGetDBResultBoth()
Returns the driver-specific value for a fetch type that includes both associative and numeric arrays.
public
GetDBResultBoth() : int
Return values
intGetDBResultNum()
Returns the driver-specific value for a numeric array fetch type.
public
GetDBResultNum() : int
Return values
intGetDBTable()
Returns the name of the current main table
public
GetDBTable() : string
Return values
string —name of the main reference table
GetFetchArray()
Fetches a result row as an array (both numeric and associative).
public
GetFetchArray([int|null $pos_row = null ]) : array<string|int, mixed>|null
Parameters
- $pos_row : int|null = null
-
position of the row to read
Return values
array<string|int, mixed>|null —the fetched row
GetFetchAssoc()
Fetches a result row as an associative array.
public
GetFetchAssoc([int|null $pos_row = null ]) : array<string|int, mixed>|null
Parameters
- $pos_row : int|null = null
-
position of the row to read
Return values
array<string|int, mixed>|null —the fetched row
GetFetchRow()
Fetches a result row as a numeric array.
public
GetFetchRow([int|null $pos_row = null ]) : array<string|int, mixed>|null
Parameters
- $pos_row : int|null = null
-
position of the row to read
Return values
array<string|int, mixed>|null —the fetched row
GetIDsArray()
Fetches a single column from the last query result into an array.
public
GetIDsArray([int|string $item = 0 ][, int|string|null $idx = null ]) : array<string|int, mixed>
Parameters
- $item : int|string = 0
-
The column index or name to fetch.
- $idx : int|string|null = null
-
The column index or name to use as the array key.
Return values
array<string|int, mixed> —An array of values.
GetLastDBErrorNumber()
Gets any error number issued by the DB.
public
static GetLastDBErrorNumber() : int
Return values
int —integer value containing the error issued by the DB
GetLastDBErrorString()
Gets any error string issued by the DB.
public
static GetLastDBErrorString() : string
Return values
string —containing the error issued by the DB
GetLastID()
Returns the ID of the last inserted item
public
GetLastID() : int|null
Return values
int|null —The ID of the last inserted element, or null on failure.
GetNextID()
Returns the next ID from a sequence or similar.
public
GetNextID([string $table = '' ]) : int|null
Parameters
- $table : string = ''
-
the name of counter associated to SEQUENCE
Return values
int|null —the next ID of the table
GetQueryDataTable()
Queries the DB and returns the result in a two-dimensional array.
public
GetQueryDataTable(array<string|int, mixed> &$data, CSqlComposer $sql[, int|null $type = null ][, string|null $with_index = null ]) : int|null
Parameters
- $data : array<string|int, mixed>
-
array containing the records found
- $sql : CSqlComposer
-
the query to execute
- $type : int|null = null
-
fetch type using generic constants (IDBMS::DB_ASSOC, etc.)
- $with_index : string|null = null
-
field name to use as the index of the main array
Return values
int|null —the total of records found or null on error
GetQueryDataValue()
Executes a query and fetches a single value.
public
GetQueryDataValue(CSqlComposer $sql[, string $name_col = '0' ][, int|null $pos_row = null ]) : string|null
Parameters
- $sql : CSqlComposer
-
The SQL query string.
- $name_col : string = '0'
-
The column name or index.
- $pos_row : int|null = null
-
The row number.
Return values
string|null —The fetched value or null.
GetQueryFetchAssoc()
Executes a query and fetches a single row as an associative array.
public
GetQueryFetchAssoc(CSqlComposer $sql[, int|null $pos_row = null ]) : array<string|int, mixed>|null
Parameters
- $sql : CSqlComposer
-
The SQL query string.
- $pos_row : int|null = null
-
The row number to fetch.
Return values
array<string|int, mixed>|null —The fetched row or null.
GetQueryFetchRow()
Executes a query and fetches a single row as an numeric index array.
public
GetQueryFetchRow(CSqlComposer $sql[, int|null $pos_row = null ]) : array<string|int, mixed>|null
Parameters
- $sql : CSqlComposer
-
The SQL query string.
- $pos_row : int|null = null
-
The row number to fetch.
Return values
array<string|int, mixed>|null —The fetched row or null.
GetTableColumnNames()
Returns an array containing the names of all columns of a table.
public
GetTableColumnNames(string $tablename) : array<string|int, string>
Parameters
- $tablename : string
-
name of table
Return values
array<string|int, string> —an array with all field names
GetTotalColumns()
Returns the number of columns of a previously executed query.
public
GetTotalColumns() : int|bool
Return values
int|bool —total of the columns or false on error
GetTotalRows()
Reads the total number of rows from a previously executed query.
public
GetTotalRows() : int|bool
Return values
int|bool —total number of rows or false on error
InsertRecord()
Make an entry in the DB
public
InsertRecord(string|null $table, array<string|int, mixed> $items, array<string|int, mixed> $types) : bool
Parameters
- $table : string|null
-
name of the table
- $items : array<string|int, mixed>
-
associative array FIELD_NAME => FIELD_VALUE
- $types : array<string|int, mixed>
-
of DB table fields
Return values
bool —true if the insertion has been made
InsertRecordBatch()
Insert multiple records in a single batch operation
public
InsertRecordBatch(string|null $table, array<string|int, mixed> $items, array<string|int, mixed> $batch_data, array<string|int, mixed> $types) : bool
Parameters
- $table : string|null
-
name of the table (if null uses the default table)
- $items : array<string|int, mixed>
-
associative array with field names as keys for the first record
- $batch_data : array<string|int, mixed>
-
array of arrays, each containing values for one record
- $types : array<string|int, mixed>
-
list of types mapped one to one with fields
Return values
bool —true if successful, false otherwise
LoadAllTables()
Loads the schema of all tables into an array.
public
LoadAllTables(array<string|int, mixed> &$db_tables) : void
Parameters
- $db_tables : array<string|int, mixed>
-
list of tables to be returned
Prepare()
Prepares an SQL statement for execution.
public
Prepare(string $sql) : void
Parameters
- $sql : string
-
string containing the query to prepare
Query()
Executes a query on the DB.
public
Query(string $sql[, array<string|int, mixed> $bind_param_values = [] ][, array<string|int, mixed> $bind_param_types = [] ]) : bool
Parameters
- $sql : string
-
string containing the query to execute
- $bind_param_values : array<string|int, mixed> = []
-
deferred values for the query
- $bind_param_types : array<string|int, mixed> = []
-
DB data types
Return values
bool —true if the query was successful
Rollback()
Rolls back the current transaction.
public
Rollback() : void
SetAllModules()
Returns a list of all modules, using cache.
public
SetAllModules() : void
SetAllTables()
Returns a list of all tables, using cache.
public
SetAllTables() : array<string|int, mixed>
Tags
Return values
array<string|int, mixed> —list of all tables
SetAutoCommit()
Sets the autocommit mode.
public
SetAutoCommit([bool $bool = true ]) : void
Parameters
- $bool : bool = true
-
if is true the autocommit is running
SetDBColumns()
Loads the schema of a table's columns into an array.
public
SetDBColumns(array<string|int, mixed> &$db_cols[, string|null $table = null ]) : void
Parameters
- $db_cols : array<string|int, mixed>
-
the results to be returned
- $table : string|null = null
-
the table to be sampled
SetDBTable()
Sets the name of the reference table for the instance.
public
SetDBTable(string $table) : void
Parameters
- $table : string
-
The name of the main table to set.
UpdateRecord()
Make an update in the DB
public
UpdateRecord(string|null $table, string $conditions, array<string|int, mixed> $items, array<string|int, mixed> $conditions_values, array<string|int, mixed> $types) : bool
Parameters
- $table : string|null
-
name of the table
- $conditions : string
-
of the update
- $items : array<string|int, mixed>
-
associative array FIELD_NAME => FIELD_VALUE
- $conditions_values : array<string|int, mixed>
-
values of the conditions
- $types : array<string|int, mixed>
-
of DB table fields
Return values
bool —true if the update has been made
GetCachedData()
Retrieves data from the cache.
protected
GetCachedData(string $cache_key[, string|null $table = null ][, bool $is_global = false ]) : mixed
Parameters
- $cache_key : string
-
The key for the cache entry.
- $table : string|null = null
-
The cache area (usually the table name).
- $is_global : bool = false
-
Whether the cache is global or user-specific.
Return values
mixed —The cached data or null if not found.
GetCacheKey()
Generates a unique cache key from a string.
protected
GetCacheKey(string $key) : string
Parameters
- $key : string
-
The input string.
Return values
string —The hashed cache key.
InvalidateRelatedCache()
Invalidates the cache for a given table and its related tables.
protected
InvalidateRelatedCache(string|null $table) : void
Parameters
- $table : string|null
-
The table name to invalidate. Defaults to the current table.
SetCachedData()
Stores data in the cache.
protected
SetCachedData(string $cache_key, mixed $data[, string|null $table = null ][, bool $is_global = false ]) : void
Parameters
- $cache_key : string
-
The key for the cache entry.
- $data : mixed
-
The data to store.
- $table : string|null = null
-
The cache area (usually the table name).
- $is_global : bool = false
-
Whether the cache is global or user-specific.
ConvertFetchType()
Converts a generic fetch type constant to the driver-specific value.
private
ConvertFetchType(int $generic_type) : int
Parameters
- $generic_type : int
-
The generic type (IDBMS::DB_ASSOC, etc.).
Return values
int —The driver-specific fetch type.
CreateDbmsDriver()
Internal factory to create the appropriate DBMS driver.
private
CreateDbmsDriver(IConnectionManager $connection_manager, string $table, ILogger|null $logger) : IDBMS
Parameters
- $connection_manager : IConnectionManager
-
The connection manager instance
- $table : string
-
The default table name
- $logger : ILogger|null
-
The logger instance to pass to the driver
Tags
Return values
IDBMS —The specific DBMS driver instance