[eluser]WoolyG[/eluser]
Hi all,
Has anyone come across a dbforge create_database catch-22, or is there a way around the below? I'm looking to allow a user to set their own database name, and have the CI app automatically install the DB, and connect to it.
Say I have a fresh CI install with the database library autoloaded, with the following settings:
Code:
$db['default']['hostname'] = 'localhost';
$db['default']['username'] = 'root';
$db['default']['password'] = 'root';
$db['default']['database'] = ''; // No DB set yet
$db['default']['dbdriver'] = 'mysql';
$db['default']['dbprefix'] = '';
$db['default']['pconnect'] = TRUE;
...
In dbforge, using $this->dbforge->create_database('db_name') is all fine & well, but the application/config/database.php needs to be manually updated also. I'm trying to keep away from manual file configuration on the part of the user as much as possible.
Here's the catch-22:
- If I use $this->dbforge->create_database() without updating database.php manually, I get a DB error requiring me to set a DB name.
- If I manually set a DB name in database.php without first creating the database (manually), I get a DB error saying CI cannot select the named DB.
Is there a way of using dbforge to create a DB, and have CI update its database.php to utilise the specified DB?
All input appreciated.
WoolyG