![]() |
Retrieving database parameter for connection - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20) +--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forumdisplay.php?fid=23) +--- Thread: Retrieving database parameter for connection (/showthread.php?tid=5112) |
Retrieving database parameter for connection - El Forum - 01-07-2008 [eluser]abmcr[/eluser] I want to get in an array or in a string the data for connecting at the database stored in config/database.php I have tried with Code: $a=$this->config->load("database",TRUE); but i get an error message.... Retrieving database parameter for connection - El Forum - 01-07-2008 [eluser]Craig A Rodway[/eluser] What error message... ? Retrieving database parameter for connection - El Forum - 01-07-2008 [eluser]abmcr[/eluser] An Error Was Encountered Your database.php file does not appear to contain a valid configuration array. Retrieving database parameter for connection - El Forum - 01-07-2008 [eluser]Craig A Rodway[/eluser] Could you post the contents of your config/database.php file (obviously changing usernames/passwords first)? Retrieving database parameter for connection - El Forum - 01-07-2008 [eluser]abmcr[/eluser] Code: .... Retrieving database parameter for connection - El Forum - 01-07-2008 [eluser]Craig A Rodway[/eluser] That file looks OK. I think you are trying to access the config settings incorrectly. The documentation does not mention any return values for $this->config->load(). To access the data yo need to use $this->config->item() - More info. Retrieving database parameter for connection - El Forum - 01-07-2008 [eluser]abmcr[/eluser] I have tried with Code: echo $this->onfig->name("username"); Retrieving database parameter for connection - El Forum - 01-07-2008 [eluser]xwero[/eluser] The database config is not a normal config file and the database class is not set up to extract the values from the config file so you could add following method to the MY_Config class Code: function dbitem($str = null,$group= 'default') Code: $this->config->dbitem('username'); Retrieving database parameter for connection - El Forum - 01-07-2008 [eluser]abmcr[/eluser] Thank you: all work fine. the correct function is Code: function dbitem($str = null,$group= 'default') Code: echo $this->dbitem('username'); Ciao !!! |