[eluser]chejnik[/eluser]
Hello,
I will post my sollution for other users.
In step 4 of installation I gathered database information and in step 5 I wrote them to config file
Code:
function install5()
{
$myDatabaseSettings = array ( 'myDatabaseSettings' => array (
'hostname' => $_POST["hostname"],
'database' => $_POST["database"],
'username' => $_POST["username"],
'password' => $_POST["password"],
'dbdriver' => $_POST["dbdriver"],
'dbprefix' => $_POST["dbprefix"],
'pconnect' => TRUE,
'db_debug' => TRUE,
'cache_on' => FALSE,
'cachedir' => "",
'char_set' => "utf8",
'dbcollat' => "utf8_general_ci"
),
);
$this->makeConfigNew($myDatabaseSettings); // call to function bellow
$this->load->view('install/installview5', $data);
}
And function that writes the database config array into file (this time called mydatabase.php)
Code:
function makeConfigNew($toconfig)
{
$myDatabaseSettings2 = array ( 'default' =>
array (
'hostname' => "localhost",
'database' => "",
'username' => "root",
'password' => "",
'dbdriver' => "mysql",
'dbprefix' => "",
'pconnect' => TRUE,
'db_debug' => TRUE,
'cache_on' => FALSE,
'cachedir' => "",
'char_set' => "utf8",
'dbcollat' => "utf8_general_ci"
),
);
$result = array_merge($myDatabaseSettings2, $toconfig);
$data = '<?php' . "\n" . 'if (!defined("BASEPATH")) exit("No direct script access allowed");' . "\n";
$data .= '$active_group = "myDatabaseSettings";';
$data .= "\n";
$data .= '$active_record = TRUE;';
$data .= "\n";
$data .= "\n";
$data .= '$db = ' . var_export($result, true) . "\n" . '?>';
write_file(APPPATH . '/config/mydatabase.php', $data, 'w+');
log_message('info', "we make a config file");
}
Hopefully it will help someone. Bye bye Ales