On the fly database setup |
[eluser]mscahill[/eluser]
I'm attempting to set up my CI application to install itself on first run ala Wordpress. I'm having trouble trying to coneptualize a way of setting the database configuration on the fly during the installation process. Any ideas?
[eluser]obiron2[/eluser]
how about checking for the database connection and if it fails on database server found but database not found, redirect to a controller/function that creates the database and the relevant tables. If you are using MySQL, you may even be able to call a shell script to create the database Obiron
[eluser]mscahill[/eluser]
I already have the installation function in place, but I need a way to set the actual connection details (host, username, password) in config/database.php
[eluser]Rob W[/eluser]
Would the following work? * Distribute the app with some specific values in the DB config ('demo_username' for example) * Find & replace these values with the new ones * Save the file Code: // Open the db config file - mode = read + write from beginning Obviously with better error checking - and you'll need to be very careful about validation on the provided options, otherwise somebody could inject some nasty raw PHP code into your config file. Hope that helps... -R
[eluser]mscahill[/eluser]
How would you even be able to trap the connection error on autoload, though?
[eluser]mscahill[/eluser]
Still haven't found a solution to this yet. Do I really have to hack the core to trap the first run database error? I need to be able to set up host, username, and password in my installation controller. Any ideas?
[eluser]mkhairul[/eluser]
The best example right now might be Derek's Bamboo Invoice. Check it out.
[eluser]Tom Schlick[/eluser]
you could always load the db values from the db haha jk |
Welcome Guest, Not a member yet? Register Sign In |