Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
Public Member Functions | Static Public Member Functions | Protected Member Functions | Protected Attributes
Zend_Log_Writer_Db Class Reference
Inheritance diagram for Zend_Log_Writer_Db:
Zend_Log_Writer_Abstract Zend_Log_FactoryInterface

Public Member Functions

 __construct ($db, $table, $columnMap=null)
 
 setFormatter (Zend_Log_Formatter_Interface $formatter)
 
 shutdown ()
 
- Public Member Functions inherited from Zend_Log_Writer_Abstract
 addFilter ($filter)
 
 setFormatter (Zend_Log_Formatter_Interface $formatter)
 
 shutdown ()
 

Static Public Member Functions

static factory ($config)
 

Protected Member Functions

 _write ($event)
 
- Protected Member Functions inherited from Zend_Log_Writer_Abstract
 _write ($event)
 

Protected Attributes

 $_db
 
 $_table
 
 $_columnMap
 
- Protected Attributes inherited from Zend_Log_Writer_Abstract
 $_filters = array()
 
 $_formatter
 

Additional Inherited Members

- Static Protected Member Functions inherited from Zend_Log_Writer_Abstract
static _parseConfig ($config)
 

Detailed Description

Definition at line 34 of file Db.php.

Constructor & Destructor Documentation

◆ __construct()

__construct (   $db,
  $table,
  $columnMap = null 
)

Class constructor

Parameters
Zend_Db_Adapter$dbDatabase adapter instance
string$tableLog table in database
array$columnMap
Returns
void

Definition at line 65 of file Db.php.

66  {
67  $this->_db = $db;
68  $this->_table = $table;
69  $this->_columnMap = $columnMap;
70  }
$table
Definition: trigger.php:14

Member Function Documentation

◆ _write()

_write (   $event)
protected

Write a message to the log.

Parameters
array$eventevent data
Returns
void
Exceptions
Zend_Log_Exception

Definition at line 127 of file Db.php.

128  {
129  if ($this->_db === null) {
130  #require_once 'Zend/Log/Exception.php';
131  throw new Zend_Log_Exception('Database adapter is null');
132  }
133 
134  if ($this->_columnMap === null) {
135  $dataToInsert = $event;
136  } else {
137  $dataToInsert = array();
138  foreach ($this->_columnMap as $columnName => $fieldKey) {
139  if (isset($event[$fieldKey])) {
140  $dataToInsert[$columnName] = $event[$fieldKey];
141  }
142  }
143  }
144 
145  $this->_db->insert($this->_table, $dataToInsert);
146  }

◆ factory()

static factory (   $config)
static

Create a new instance of Zend_Log_Writer_Db

Parameters
array | Zend_Config$config
Returns
Zend_Log_Writer_Db

Implements Zend_Log_FactoryInterface.

Definition at line 78 of file Db.php.

79  {
81  $config = array_merge(array(
82  'db' => null,
83  'table' => null,
84  'columnMap' => null,
85  ), $config);
86 
87  if (isset($config['columnmap'])) {
88  $config['columnMap'] = $config['columnmap'];
89  }
90 
91  return new self(
92  $config['db'],
93  $config['table'],
94  $config['columnMap']
95  );
96  }
$config
Definition: fraud_order.php:17
static _parseConfig($config)
Definition: Abstract.php:126

◆ setFormatter()

setFormatter ( Zend_Log_Formatter_Interface  $formatter)

Formatting is not possible on this writer

Returns
void
Exceptions
Zend_Log_Exception

Definition at line 104 of file Db.php.

105  {
106  #require_once 'Zend/Log/Exception.php';
107  throw new Zend_Log_Exception(get_class($this) . ' does not support formatting');
108  }

◆ shutdown()

shutdown ( )

Remove reference to database adapter

Returns
void

Definition at line 115 of file Db.php.

116  {
117  $this->_db = null;
118  }

Field Documentation

◆ $_columnMap

$_columnMap
protected

Definition at line 55 of file Db.php.

◆ $_db

$_db
protected

Definition at line 41 of file Db.php.

◆ $_table

$_table
protected

Definition at line 48 of file Db.php.


The documentation for this class was generated from the following file: