Welcome Guest, Not a member yet? Register   Sign In
[Solved] Dynamic Database Settings

Hi everybody !!
I'm a new user of CodeIgniter (I'm using generaly Zend Framework but for a small website, this one is way lighter and very easy to use !!) and I wanted to know if there is a way to enter the database name, host, user, password in a form and then complete the database.php file with those fields.
I'm not sure I'm clear but if someone understand what I'm saying ask me if you need more details !!!
Thanks everyone !


[eluser]Colin Williams[/eluser]
So long as you are comfortable with reading and writing to files in PHP, there's nothing stopping you.

Covering all bases here, in case you meant that you want to connect to a database without writing a configuration file, you do not have to auto-connect to the database or use a configuration file at all. You can pass an array as you load the database class manually.

Here's the example from the manual:

$config['hostname'] = "localhost";
$config['username'] = "myusername";
$config['password'] = "mypassword";
$config['database'] = "mydatabase";
$config['dbdriver'] = "mysql";
$config['dbprefix'] = "";
$config['pconnect'] = FALSE;
$config['db_debug'] = TRUE;
$config['cache_on'] = FALSE;
$config['cachedir'] = "";
$config['char_set'] = "utf8";
$config['dbcollat'] = "utf8_general_ci";


Your array values can be set dynamically of course (be careful!)

Thanks a lot for this answer (sorry to be late I didn't receive a notification ^^)
I think it will be ok for my problem!
Thanks !

Theme © iAndrew 2016 - Forum software by © MyBB