Welcome Guest, Not a member yet? Register   Sign In
Showing database connection parameters
#1

[eluser]mdzwarts[/eluser]
I want to retrieve information about the database i've connected, to inform the user which database they are using right now. I have a custom class for my standard output components from which I want to collect this info. How do I do this, properly?

I've tried out:
Code:
$LIB =& get_instance();
$LIB->$db['default']['database'];
and:

Code:
$db['default']['database'];

and:

Code:
config_item('database')

..but no such luck. It would seem to me none of the above should actually work, but I'm fairly new to both php and code igniter.Reason I want to be able to display, is that we will be using multiple environments, and making sure by visual check is a good way to know if we are editing the right database.
#2

[eluser]gtech[/eluser]
hello, try:
Code:
echo $this->db->database;

see

system\database\DB_driver.php for a list of variables in the db object
#3

[eluser]mdzwarts[/eluser]
That works.
As I'm in a custom library I used
Code:
$LIB =& get_instance();
$LIB->db->database
#4

[eluser]gtech[/eluser]
ahhh im with you, I assumed you were in a controller, anyway glad you got it working.
#5

[eluser]mdzwarts[/eluser]
Thanks a lot for your input.




Theme © iAndrew 2016 - Forum software by © MyBB