Modules

Kohana_Config_Database_Reader

Implements: Kohana_Config_Reader | Kohana_Config_Source

This class is a transparent base class for Config_Database_Reader and should not be accessed directly.

Database reader for the kohana config system

package
Kohana/Database
category
Configuration
author
Kohana Team
copyright
© 2012 Kohana Team
license
https://kohana.top/license

Class declared in MODPATH/database/classes/Kohana/Config/Database/Reader.php on line 12.

Constants

  • None

Properties

protected $_db_instance

Default value:
NULL

protected $_table_name

Default value:
string(6) "config"

Methods

public __construct( [ array $config = NULL ] ) (defined in Kohana_Config_Database_Reader)

Constructs the database reader object

Parameters

  • array $config = NULL - Configuration for the reader

Source Code

public function __construct(array $config = null)
{
    if (isset($config['instance'])) {
        $this->_db_instance = $config['instance'];
    } elseif ($this->_db_instance === null) {
        $this->_db_instance = Database::$default;
    }

    if (isset($config['table_name'])) {
        $this->_table_name = $config['table_name'];
    }
}

public load( string $group ) (defined in Kohana_Config_Database_Reader)

Tries to load the specificed configuration group

Returns false if group does not exist or an array if it does

Parameters

  • string $group required - Configuration group

Return Values

  • boolean|array

Source Code

public function load($group)
{
    /**
     * Prevents the catch-22 scenario where the database config reader attempts to load the
     * database connections details from the database.
     *
     * @link http://dev.kohanaframework.org/issues/4316
     */
    if ($group === 'database')
        return false;

    $query = DB::select('config_key', 'config_value')
        ->from($this->_table_name)
        ->where('group_name', '=', $group)
        ->execute($this->_db_instance);

    return count($query) ? array_map('unserialize', $query->as_array('config_key', 'config_value')) : false;
}