Testing database connections |
Using $this->load->database(); will throw a error page if the connection failed or for example the config file does not exists. And this behavior can not be overwritten.
From @BenHeadrick first post, that is exactly what he wants to get away from. (03-30-2015, 10:24 PM)BenHeadrick Wrote: ... without throwing any warnings. ... As far as I know, CI does not have a function that only check if it can connect to the database or not, and return true/false. For the solution though, I would close the connection before returning true/false. And then later when you need to actually use the DB, you connect with $this->load->database(); so you can use CIs query builder and more as usual. Here is an updated example. I also removed all else statement as they are not needed. PHP Code: public function check_database() |
Messages In This Thread |
Testing database connections - by BenHeadrick - 03-30-2015, 10:24 PM
RE: Testing database connections - by CroNiX - 03-31-2015, 06:55 AM
RE: Testing database connections - by BenHeadrick - 03-31-2015, 04:04 PM
RE: Testing database connections - by CroNiX - 04-01-2015, 07:14 AM
RE: Testing database connections - by silentium - 04-01-2015, 10:26 AM
RE: Testing database connections - by BenHeadrick - 04-03-2015, 07:11 PM
|