Welcome Guest, Not a member yet? Register   Sign In
Testing connection to database
#1

[eluser]Unknown[/eluser]
Hi,
In a page I would like to have a user test fill in the connection parameters to a database and then test them to see if the database is online. Is there a way that I could do that with CodeIgniter ?
I' masking that because when I'm trying a database connection that doesn't work I get the default CI exception message.
#2

[eluser]ELRafael[/eluser]
In the user_guide, database configuration, try to use the db_debug.

Or, not do the autoload database, just load in your controller with a try{} catch{}...

MAYBE this works for you
#3

[eluser]Unknown[/eluser]
$conn = @mysql_connect("localhost","root","");
if(is_resource($conn)){
$this->load->database();
$this->load->dbutil();
$data['dbs'] = $this->dbutil->list_databases();
}else{
$data['dbs'] = array();
}
$this->load->view('welcome_message',$data);
#4

[eluser]Glen Swinfield[/eluser]
eovidiu's answer should work. You need to supress the error (@) that is generated when the dbase cannot connect, in order to then deal with it yourself - i.e. tell the user the dbase is not online.




Theme © iAndrew 2016 - Forum software by © MyBB