Welcome Guest, Not a member yet? Register   Sign In
Creating Dynamically DataBase
#11

[eluser]InsiteFX[/eluser]
Did you create the the nice database config in the application/config/database.php ?
Code:
$active_group = 'default';
$active_record = TRUE;

$db['default']['hostname'] = 'localhost';
$db['default']['username'] = '';
$db['default']['password'] = '';
$db['default']['database'] = '';
$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_unicode_ci';
$db['default']['swap_pre'] = '';
$db['default']['autoinit'] = TRUE;
$db['default']['stricton'] = FALSE;

$db['nice']['hostname'] = 'localhost';
$db['nice']['username'] = '';
$db['nice']['password'] = '';
$db['nice']['database'] = '';
$db['nice']['dbdriver'] = 'mysql';
$db['nice']['dbprefix'] = '';
$db['nice']['pconnect'] = TRUE;
$db['nice']['db_debug'] = TRUE;
$db['nice']['cache_on'] = FALSE;
$db['nice']['cachedir'] = '';
$db['nice']['char_set'] = 'utf8';
$db['nice']['dbcollat'] = 'utf8_unicode_ci';
$db['nice']['swap_pre'] = '';
$db['nice']['autoinit'] = TRUE;
$db['nice']['stricton'] = FALSE;

InsiteFX
#12

[eluser]Ajaxian64[/eluser]
What I do exactly :
Code:
$active_group = 'default';
$active_record = TRUE;

$db['default']['hostname'] = 'localhost';
$db['default']['username'] = 'root';
$db['default']['password'] = '';
$db['default']['database'] = '';
$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'] = TRUE;
$db['default']['stricton'] = FALSE;

$db['nice']['hostname'] = 'localhost';
$db['nice']['username'] = 'root';
$db['nice']['password'] = '';
$db['nice']['database'] = 'nice';
$db['nice']['dbdriver'] = 'mysql';
$db['nice']['dbprefix'] = '';
$db['nice']['pconnect'] = TRUE;
$db['nice']['db_debug'] = TRUE;
$db['nice']['cache_on'] = FALSE;
$db['nice']['cachedir'] = '';
$db['nice']['char_set'] = 'utf8';
$db['nice']['dbcollat'] = 'utf8_general_ci';
$db['nice']['swap_pre'] = '';
$db['nice']['autoinit'] = TRUE;
$db['nice']['stricton'] = FALSE;
The process I did is
I test whether the database is already created, if no I create ==> This works !
But event if I do a $this->load->database('nice'); then I get a ‘Query error: No database selected’

But I become a Lab assistant thanks to this issue ...
#13

[eluser]Ajaxian64[/eluser]
And same problem when I do
Code:
$db['nice']['database'] = 'nice';
or
Code:
$db['nice']['database'] = '';
#14

[eluser]InsiteFX[/eluser]
You need to restart dbforge, it expects the database driver to be already set!

So what I think you need to do is after you create the database you need to get out of dbforge, then set the database to nice then reload dbforge then you should be able to create your table and fields.

InsiteFX
#15

[eluser]Ajaxian64[/eluser]
Sure you get the solution
But how closing dbforge ?

However I feel that's the good solution
if it is
Code:
$this->db->close
then NO effect

And to be sure that it is a problem of connecting I set default database to a database I create manualy
And the tables I tried to create on 'nice' are create on the default database
That's clearly mean that your hint was good

It stays the problem that I can't switch between db connection.
#16

[eluser]Ajaxian64[/eluser]
Okkkkkk !!!

I got the solution

To close the connection :
Code:
$this->db->close();
$this->db = null;
then restart dbforge
Thanks InsiteFX to your support
#17

[eluser]InsiteFX[/eluser]
Your very Welcome!

InsiteFX
#18

[eluser]Unknown[/eluser]
use mysqli instead of mysql!

$db['default']['dbdriver'] = 'mysqli';

try it!




Theme © iAndrew 2016 - Forum software by © MyBB