Configure database config from function |
Hi!
Is possible to set database config from normal form? Normal config has this option - ok, but now I need to set database config (hostname, user, password, etc.)
yes you can
in your database config file add as many configuration groups as the numbers of your databases: PHP Code: $db['a']['hostname'] = 'localhost'; then on your model initialize a class variable: PHP Code: private $db_b; and, into the contructor, set it as follow PHP Code: __construct() now you are able to use the database b as usual: PHP Code: $this->db_b->query('YOUR QUERY'); and obviously the default one as follow: PHP Code: $this->db->query('YOUR QUERY'); Make sure to set the persistant connect to false PHP Code: $db['a']['pconnect'] = FALSE; (02-29-2016, 08:36 AM)keulu Wrote: yes you can You don't understand - I know how to use multiple databases. I need to set config this config manualy, because I want to create installer for my APP
arf okay, my bad,
yes you can by overwriting the config file. in php you can write files http://php.net/manual/fr/function.fwrite.php you just have to remove the old database config and rewrite the new one ![]()
You can pass array of patamteres to database loader like this:
PHP Code: $config['hostname'] = 'localhost'; |
Welcome Guest, Not a member yet? Register Sign In |