Back to DatabaseLogger class

Method __construct

public
__construct
(array &$options)
Constructor.
Parameters
  • array & $options Log object options.
Since
  • 1.7.0

Method __construct - Source code

/**
 * Constructor.
 *
 * @param   array  &$options  Log object options.
 *
 * @since   1.7.0
 */
public function __construct(array &$options)
{
    // Call the parent constructor.
    parent::__construct($options);
    // If both the database object and driver options are empty we want to use the system database connection.
    if (empty($this->options['db_driver'])) {
        $this->db = Factory::getDbo();
        $this->driver = null;
        $this->host = null;
        $this->user = null;
        $this->password = null;
        $this->database = null;
        $this->prefix = null;
    } else {
        $this->db = null;
        $this->driver = empty($this->options['db_driver']) ? 'mysqli' : $this->options['db_driver'];
        $this->host = empty($this->options['db_host']) ? '127.0.0.1' : $this->options['db_host'];
        $this->user = empty($this->options['db_user']) ? 'root' : $this->options['db_user'];
        $this->password = empty($this->options['db_pass']) ? '' : $this->options['db_pass'];
        $this->database = empty($this->options['db_database']) ? 'logging' : $this->options['db_database'];
        $this->prefix = empty($this->options['db_prefix']) ? 'jos_' : $this->options['db_prefix'];
    }
    // The table name is independent of how we arrived at the connection object.
    $this->table = empty($this->options['db_table']) ? '#__log_entries' : $this->options['db_table'];
}