[eluser]chejnik[/eluser]
Hello,
I would like to release an Dictionary application, that can anyone install to your server and use it there.
Is there a simple way to override database confiration settings in config/database.php or is it better to use some new created config file with database configuration settings and other stuff?
This function I have found creates simple config array
Code:
// $toconfig is simple array like this
$toconfig = array (
'hostname' => $_POST["hostname"],
'database' => $_POST["database"],
'username' => $_POST["username"],
'password' => $_POST["password"],
'dbdriver' => $_POST["dbdriver"],
'dbprefix' => $_POST["dbprefix"],
);
function make_config($toconfig)
{
$this->config->load('myconfig', TRUE);
$myconfig = $this->config->item('myconfig');
$result = array_merge($myconfig, $toconfig);
$data = '<?php' . "\n" . 'if (!defined("BASEPATH")) exit("No direct script access allowed");' . "\n" . '$config = ' . var_export($result, true) . "\n" . '?>';
write_file(APPPATH . 'config/myconfig.php', $data);
}
I wonder how would you solve it. Thank you