Welcome Guest, Not a member yet? Register   Sign In
Writing to database.php at install time
#1

[eluser]MikeHibbert[/eluser]
Hi

I want to load and alter the database settings when i have installed my CI site.

It just seems like a good idea to be able to have a form to enter the database settings and update those setting once installed.

Would it be correct to create a new config called 'live' then set the $active_group = 'live'?

Also can active group be changed in code at runtime?

Please help

Mike
#2

[eluser]Randy Casburn[/eluser]
Hi Mike,

Yes and Yes Smile

All you would be doing is opening and changing your config file at the time of install. I'm assuming you have a script that is doing your install for you, correct? That script would then simply file_get_contents() or whatever for your db config file and change it to whatever you wanted it to be for the live implementation.

Whether that means you change one line $active_group or you change all the config variables is up to you. Either way would work.

As far as "can the active group be changed at run time" the answer (I think) is yes, any of the configuration options that are not stored as constants can be changed at run time. I said "I think" because I'm not sure what you mean when you plugged in "in code". I think you just mean "on the fly". If that's the case the answer is simply yes. All the config variables can be changed on-the-fly at run time.

Of course it's best NOT to do that, but you have your answer.

Randy




Theme © iAndrew 2016 - Forum software by © MyBB