![]() |
On the fly database setup - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20) +--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forumdisplay.php?fid=23) +--- Thread: On the fly database setup (/showthread.php?tid=13383) Pages:
1
2
|
On the fly database setup - El Forum - 11-20-2008 [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? On the fly database setup - El Forum - 11-25-2008 [eluser]mscahill[/eluser] Hello? Is anybody out there? On the fly database setup - El Forum - 11-25-2008 [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 On the fly database setup - El Forum - 11-25-2008 [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 On the fly database setup - El Forum - 12-18-2008 [eluser]mscahill[/eluser] So is this impossible? On the fly database setup - El Forum - 12-18-2008 [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 On the fly database setup - El Forum - 12-18-2008 [eluser]mscahill[/eluser] How would you even be able to trap the connection error on autoload, though? On the fly database setup - El Forum - 01-13-2009 [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? On the fly database setup - El Forum - 01-13-2009 [eluser]mkhairul[/eluser] The best example right now might be Derek's Bamboo Invoice. Check it out. On the fly database setup - El Forum - 01-13-2009 [eluser]Tom Schlick[/eluser] you could always load the db values from the db ![]() |