[eluser]Ajaxian64[/eluser]
Hi all,
I'm trying to create an application on which, the first time it is launched aims to create a database.
When I start the application, I try to know where if the database is already created.
But unfortunatly, and because I think I misunderstand something I fail to my mission.
To sum up what I did
In database.php config I filled this :
Code:
$active_group = 'default';
$active_record = TRUE;
$db['default']['hostname'] = 'localhost';
$db['default']['username'] = 'root';
$db['default']['password'] = '';
$db['default']['database'] = 'nice';
$db['default']['dbdriver'] = 'mysql';
$db['default']['dbprefix'] = '';
$db['default']['pconnect'] = TRUE;
$db['default']['db_debug'] = TRUE;
$db['default']['cache_on'] = FALSE;
$db['default']['cachedir'] = '';
$db['default']['char_set'] = 'utf8';
$db['default']['dbcollat'] = 'utf8_general_ci';
$db['default']['swap_pre'] = '';
$db['default']['autoinit'] = FALSE;
$db['default']['stricton'] = FALSE;
in my step1 controller in the index I try to detect whether the "nice" database has already been created
Code:
function index()
{
$this->load->database();
/* ******************************************** */
/* Création des tables de la base de données */
/* ******************************************** */
$this->load->dbutil();
// Création des tables si database non créee
if ( ! $this->dbutil->database_exists('nice') ) {
$this->load->dbforge();
// In this
$this->dbforge->create_database('nice');
}
// Others stuff ....
}
But the
Code:
$this->dbutil->database_exists('nice')
fails and the message is
Database config for development environment is not found. Trying global config.
and this outpu message on browser :
A Database Error Occurred
Unable to select the specified database: nice
Filename: D:\wamp\www\Idomat\system\database\DB_driver.php
Line Number: 140
Finally, I doubt about my understanding of the database_exists function.
Does someone have an explain about this behavior ?
Thanks