Constants

WRITER_PREFIX

WRITER_PREFIX

Prefix for ini files.

CONN_PARAM_DEFAULT_INI

CONN_PARAM_DEFAULT_INI

default name for connection parameter ini file.

DATATYPE_MAPPINGS_DEFAULT_INI

DATATYPE_MAPPINGS_DEFAULT_INI

default name for datatype mappings ini file.

META_SUFFIX

META_SUFFIX

Meta table suffix.

Properties

$state

$state : 

Type

$error

$error : 

Type

$warning

$warning : 

Type

$ready

$ready : 

Type

$timestampFormat

$timestampFormat : 

Currently not used

Type

$log_timestamp

$log_timestamp : 

Currently not used

Type

$dbconn

$dbconn : 

Type

$_writerParams

$_writerParams : 

Type

$_datatypeMappings

$_datatypeMappings : 

Type

$_datatypeMappingsDefault

$_datatypeMappingsDefault : 

Type

Methods

__construct()

__construct(array  $connectionParams, array  $writerParams = null) 

Parameters

array $connectionParams

Doctrine 2 DBAL connection parameter set

array $writerParams

"table" (string): Name for logs table (default = "access_log"). "safety" (int): Safety levels as defined in "DatabaseLogWriterHelper". "datatype_mappings_replace_defaults" (boolean): replace internal defaults entirely ("true") or make up/overwrite defaults ("false").

writeToLog()

writeToLog(array  $regularFields, array  $metaFields = null) 

Write log fields to a database

Parameters

array $regularFields

The associative array containing all fields to write (representing a logfile entry), datatype and content.

array $metaFields

The associative array containing all meta fields to write (into a separate table).

fetchMetaDataFromDB()

fetchMetaDataFromDB() : array

Return data from meta table (if available, null otherwise)

Returns

array

mapDBALDataType()

mapDBALDataType(string  $datatype) : array

Map the given basic (phpWTL) data type/alias to Doctrine DBAL conform data type and default portable options.

Parameters

string $datatype

data type or alias, as set in a format descriptor

Returns

array —

Doctrine DBAL data type (key: "datatype") and default portable options (key: "options"). Null if given type/alias is unknown/not supported

getDBALDataType()

getDBALDataType(string  $datatype) : string

Get the Doctrine data type for a given basic (phpWTL) data type or alias.

Parameters

string $datatype

data type or alias, as set in a format descriptor

Returns

string —

Doctrine DBAL data type, null if given type/alias is unknown/not supported

getDataTypeDefaultsForDBAL()

getDataTypeDefaultsForDBAL(string  $datatype) : array

Get the defaults (portable options) for a given basic (phpWTL) data type or alias.

Parameters

string $datatype

data type or alias, as set in a format descriptor

Returns

array —

default portable options, null if given type/alias is unknown/not supported or there are no options available

initDatatypeMappings()

initDatatypeMappings() 

Initialize the (custom) datatype mappings.

initDatatypeMappingsDefault()

initDatatypeMappingsDefault() 

Initialize the datatype mappings default.

getDatatypeMappingsDefault()

getDatatypeMappingsDefault() : array

Get the datatype mappings default.

Returns

array

getDatatypeMappings()

getDatatypeMappings() : array

Get the datatype mappings in effect.

Returns

array

dbFriendlyName()

dbFriendlyName(string  $name, integer  $strategy) : string

Return cleansed (db name safe) version of given string, use "$strategy" to cleanse: SAFE_NAMING_STRATEGY_WTL_CLEANSING (default): Least common denominator of a string used as a database table/column name (remove all characters other than a-z and underscore and convert to lowercase).

SAFE_NAMING_STRATEGY_DBAL_ESCAPING: Doctrine DBAL escaping via "quoteIdentifier" method.

Parameters

string $name
integer $strategy

Safe naming strategy

Returns

string

initWriter()

initWriter(array  $connectionParams, array  $writerParams) 

Initialize the writer.

Parameters

array $connectionParams

Doctrine 2 DBAL connection parameter set

array $writerParams

See constructor

getSchemaDiffQuery()

getSchemaDiffQuery(array  $fields, boolean  $meta,   $safety) : array

Get SQL queries to update logger table

Parameters

array $fields

Field names.

boolean $meta

If set fields are supposed to be stored in the meta table.

$safety

Returns

array —

Queries neccessary for all changes

getLogTimestamp()

getLogTimestamp() 

Currently not used.

writeToLogQB()

writeToLogQB(string  $table, array  $fields,   $update = false) 

Write data using DBAL QueryBuilder

Parameters

string $table

Table name to write to

array $fields

The associative array containing all fields to write (representing a logfile entry), datatype and content.

$update