[eluser]gh0st[/eluser]
I'm wanting to "hook" database configuration files from another system so that I only have to change the db details once, in one file.
I don't want to be hacking the database config file, so I thought hooks might be able to help;
Code:
// config hooks.php
$hook['pre_system'] = array
(
'class' => 'MyClass',
'function' => 'Myfunction',
'filename' => 'Myclass.php',
'filepath' => 'hooks'
);
Code:
<?php
class MyClass
{
function MyClass()
{
}
function Myfunction()
{
include_once("../config.inc.php");
$db['default']['hostname'] = $database_server;
$db['default']['username'] = $database_user;
$db['default']['password'] = $database_password;
$db['default']['database'] = $dbase;
$db['default']['dbdriver'] = $database_type;
$db['default']['dbprefix'] = $table_prefix;
$db['default']['char_set'] = $database_connection_charset;
return $db;
}
}
?>
I've tested the details in the Myfunction and they are working -- but the DB config never changes.
I've even outputted the DB config file, ensuring that the original details do not overwrite my hook -- but nothing ever changes.
How do I get CI to hook another database config?
Thanks