Welcome Guest, Not a member yet? Register   Sign In
Change DB config
#1

Hi everyone,

I try to make a login to my DB (directly to the DB, not to a table containing users)

But I don't know how could I change the configuration in the default database

For example this could be the begining : 

PHP Code:
$db['default'] = array(
    
'dsn'    => '',
    
'hostname' => $tnsname,
    
'username' => '',
    
'password' => '',
    
'database' => '',
    
'dbdriver' => 'oci8',
    
'dbprefix' => ''

And then in the controller, change the $username and $passeword with variables so I can login.

Can anyone help me in this case ? any tips ?
Reply
#2

@arber.smajli,

You can have multiple database configurations. See documentation: https://www.codeigniter.com/user_guide/d...-databases
Reply
#3

Thank you for your message

I see what you mean but it's not what I search.

I will try to explain you differently ;

I am making a database monitor, so to acces to the page, the admin have to connect to the database.

So, in first case, the database configuration (application/config/database.php) is empty.

And if the admin enter the correct username/passeword (of the database) he is loged on.

This is what I can't do for the moment, write in application/config/database.php from a controller.

So if anyone has an idea, it would be cool.
Reply
#4

You can still use generic MySQLi to access your databases etc;
What did you Try? What did you Get? What did you Expect?

Joined CodeIgniter Community 2009.  ( Skype: insitfx )
Reply
#5

The thing is I use Oracle databases
Reply
#6

(08-01-2018, 11:42 PM)arber.smajli Wrote: Thank you for your message

I see what you mean but it's not what I search.

I will try to explain you differently ;

I am making a database monitor, so to acces to the page, the admin have to connect to the database.

So, in first case, the database configuration (application/config/database.php) is empty.

And if the admin enter the correct username/passeword (of the database) he is loged on.

This is what I can't do for the moment, write in application/config/database.php from a controller.

So if anyone has an idea, it would be cool.

I understand what you are saying.  There are many approaches that you an take.  I will give you two off the top of my head...
  1. You could create a library/script that will automatically update the config file adding the new connections details.  Also, the script should be able to remove them as well.
  2. You could create a library/script that will use the default PHP connection string and encypt and save the database login information as it is added by the user.
And I'm quite sure others may have other suggestions.
Reply




Theme © iAndrew 2016 - Forum software by © MyBB