Search code examples
databaseweb-applicationsconfigurationweb-configkohana

Storing configuration in database


I'm having a problem with my application configuration. It's based on KohanaPHP framework, currently I store configuration in custom config file:

$config['status'] = array(
    '1' => 5,
    '2' => 10,
    '3' => 15,
    '4' => 20,
    '5' => 25,
    '6' => 30
);

and then in view/controller (when needed):

$arr = Kohana::config('settings.status'); echo $arr[$item->status]

Now I'm looking for the best method to store such config arrays in database.

What would you recommend? Separate tables? Putting everything in one table? Would you give me a tip?

Cheers, M.


Solution

  • Kohana already has a database configuration reader/writer:

    // In bootstrap.php
    Kohana::$config->attach(new Kohana_Config_Database);
    

    The class Kohana_Config_Database is in the database module.