Documentation

Mage_Core_Model_Resource
in package

Table of Contents

Constants

AUTO_UPDATE_ALWAYS  : mixed = 1
AUTO_UPDATE_CACHE_KEY  : mixed = 'DB_AUTOUPDATE'
AUTO_UPDATE_NEVER  : mixed = -1
AUTO_UPDATE_ONCE  : mixed = 0
DEFAULT_READ_RESOURCE  : mixed = 'core_read'
DEFAULT_SETUP_RESOURCE  : mixed = 'core_setup'
DEFAULT_WRITE_RESOURCE  : mixed = 'core_write'

Properties

$_connections  : array<string|int, AdapterInterface>|false
Instances of actual connections
$_connectionTypes  : array<string|int, mixed>
Instances of classes for connection types
$_entities  : array<string|int, mixed>
Registry of resource entities
$_mappedTableNames  : array<string|int, mixed>
Mapped tables cache array
$_skippedConnections  : array<string|int, mixed>
Names of actual connections that wait to set cache

Methods

checkDbConnection()  : mixed
closeConnections()  : void
Release every open connection, reconnecting on next use. Several names share one adapter, so each is closed once.
createConnection()  : AdapterInterface
Create new connection with custom config
createUnsharedConnection()  : AdapterInterface
Build a connection that is not registered in $_connections. It shares no transaction and no session state with the rest of the request. The caller must close it.
getAutoUpdate()  : int
getConnection()  : AdapterInterface|false
Creates a connection to resource whenever needed
getConnections()  : array<string|int, AdapterInterface>|false
Get Instances of actual connections
getConnectionTypeInstance()  : Mage_Core_Model_Resource_Type_Abstract
Get connection type instance
getEntity()  : SimpleXMLElement|Config
Get resource entity
getFkName()  : string
Retrieve 32bit UNIQUE HASH for a Table foreign key
getIdxName()  : AdapterInterface|false
Retrieve 32bit UNIQUE HASH for a Table index
getMappedTableName()  : bool|string
Get mapped table name
getTableName()  : string
Get resource table name, validated by db adapter
isLegacyCharsetStatement()  : bool
Tell if $statement is the `SET NAMES utf8` that older installers wrote to local.xml. It sets the connection back to utf8mb3, and the adapter already sets utf8mb4, so the caller must not run it.
runOutsideTransaction()  : T
Run a callback on a connection that is not inside a transaction.
setAutoUpdate()  : $this
setMappedTableName()  : $this
Set mapped table name
_getConnectionAdapterClassName()  : string|false
Retrieve connection adapter class name by connection type
_getConnectionType()  : string
Determine connection type from config
_getDefaultConnection()  : AdapterInterface|false
Retrieve default connection name by required connection name
_newConnection()  : AdapterInterface|false
Create new connection adapter instance by connection type and config

Constants

AUTO_UPDATE_ALWAYS

public mixed AUTO_UPDATE_ALWAYS = 1

AUTO_UPDATE_CACHE_KEY

public mixed AUTO_UPDATE_CACHE_KEY = 'DB_AUTOUPDATE'

AUTO_UPDATE_NEVER

public mixed AUTO_UPDATE_NEVER = -1

AUTO_UPDATE_ONCE

public mixed AUTO_UPDATE_ONCE = 0

DEFAULT_READ_RESOURCE

public mixed DEFAULT_READ_RESOURCE = 'core_read'

DEFAULT_SETUP_RESOURCE

public mixed DEFAULT_SETUP_RESOURCE = 'core_setup'

DEFAULT_WRITE_RESOURCE

public mixed DEFAULT_WRITE_RESOURCE = 'core_write'

Properties

$_connectionTypes

Instances of classes for connection types

protected array<string|int, mixed> $_connectionTypes = []

$_entities

Registry of resource entities

protected array<string|int, mixed> $_entities = []

$_mappedTableNames

Mapped tables cache array

protected array<string|int, mixed> $_mappedTableNames

$_skippedConnections

Names of actual connections that wait to set cache

protected array<string|int, mixed> $_skippedConnections = []

Methods

checkDbConnection()

public checkDbConnection() : mixed
Attributes
#[Observer]
'controller_action_predispatch'
$area: 'install'

closeConnections()

Release every open connection, reconnecting on next use. Several names share one adapter, so each is closed once.

public closeConnections() : void

createConnection()

Create new connection with custom config

public createConnection(string $name, string $type, array<string|int, mixed> $config) : AdapterInterface
Parameters
$name : string
$type : string
$config : array<string|int, mixed>
Return values
AdapterInterface

createUnsharedConnection()

Build a connection that is not registered in $_connections. It shares no transaction and no session state with the rest of the request. The caller must close it.

public createUnsharedConnection([string $name = self::DEFAULT_WRITE_RESOURCE ]) : AdapterInterface
Parameters
$name : string = self::DEFAULT_WRITE_RESOURCE
Tags
throws
Mage_Core_Exception
Return values
AdapterInterface

getAutoUpdate()

public getAutoUpdate() : int
Return values
int

getEntity()

Get resource entity

public getEntity(string $model, string $entity) : SimpleXMLElement|Config
Parameters
$model : string
$entity : string
Return values
SimpleXMLElement|Config

getFkName()

Retrieve 32bit UNIQUE HASH for a Table foreign key

public getFkName(array<string|int, mixed>|string $priTableName, string $priColumnName, string $refTableName, string $refColumnName) : string
Parameters
$priTableName : array<string|int, mixed>|string

the target table name

$priColumnName : string

the target table column name

$refTableName : string

the reference table name

$refColumnName : string

the reference table column name

Return values
string

getMappedTableName()

Get mapped table name

public getMappedTableName(string $tableName) : bool|string
Parameters
$tableName : string
Return values
bool|string

getTableName()

Get resource table name, validated by db adapter

public getTableName(string|array<string|int, mixed> $modelEntity) : string
Parameters
$modelEntity : string|array<string|int, mixed>
Tags
throws
Mage_Core_Exception
Return values
string

isLegacyCharsetStatement()

Tell if $statement is the `SET NAMES utf8` that older installers wrote to local.xml. It sets the connection back to utf8mb3, and the adapter already sets utf8mb4, so the caller must not run it.

public static isLegacyCharsetStatement(string $statement) : bool
Parameters
$statement : string
Return values
bool

runOutsideTransaction()

Run a callback on a connection that is not inside a transaction.

public runOutsideTransaction(callable(AdapterInterface): T $callback[, string $name = self::DEFAULT_WRITE_RESOURCE ]) : T

beginTransaction() issues a real BEGIN only at level 0. Nested, a SELECT ... FOR UPDATE joins the read view of the caller. MariaDB innodb_snapshot_isolation then aborts that caller with ER_CHECKREAD (1020).

A connection is opened only when the shared one is in a transaction, and is closed again before this method returns. The callback can commit while the caller rolls back later.

Parameters
$callback : callable(AdapterInterface): T
$name : string = self::DEFAULT_WRITE_RESOURCE
Tags
template
Return values
T

setAutoUpdate()

public setAutoUpdate(mixed $value) : $this
Parameters
$value : mixed
Return values
$this

setMappedTableName()

Set mapped table name

public setMappedTableName(string $tableName, string $mappedName) : $this
Parameters
$tableName : string
$mappedName : string
Return values
$this

_getConnectionAdapterClassName()

Retrieve connection adapter class name by connection type

protected _getConnectionAdapterClassName(string $type) : string|false
Parameters
$type : string

the connection type

Return values
string|false

_getConnectionType()

Determine connection type from config

protected _getConnectionType(Mage_Core_Model_Config_Element $connConfig) : string

Supports new 'engine' config (mysql, pgsql, sqlite) which derives type as pdo_{engine}, with backward compatibility for legacy 'type' and 'model' configs.

Parameters
$connConfig : Mage_Core_Model_Config_Element
Return values
string

_getDefaultConnection()

Retrieve default connection name by required connection name

protected _getDefaultConnection(string $requiredConnectionName) : AdapterInterface|false
Parameters
$requiredConnectionName : string
Return values
AdapterInterface|false
On this page

Search results