CodeIgniter 2.x and shutdown database - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: Using CodeIgniter (https://forum.codeigniter.com/forumdisplay.php?fid=5) +--- Forum: General Help (https://forum.codeigniter.com/forumdisplay.php?fid=24) +--- Thread: CodeIgniter 2.x and shutdown database (/showthread.php?tid=760) |
CodeIgniter 2.x and shutdown database - UchihaSV - 01-14-2015 I have some database connections, and i load database in controller if necessary. And i want continue my script work, if database is shutdown. But if some database is shutdown, my script stopped with error: "unable connect to database". And i'm solve this problem (db_gebug = FALSE), and now my script also stopped and i see error "undefined variable DB2" from model file, this tell me about CodeIgniter db connection not returning FALSE in my var. My script logic in controller: > ....... > $DB2 = $this->load->database('db2', TRUE, TRUE); > if ($DB2) { > $this->load->model('some_model'); > //actions > } > else $data['content'] = 'server now is shutdown'; > ....... Result: var DB2 not gain FALSE, if mysql server is shutdown, and my script logic not work, and i have errors. And if i change "if ($DB2)" to "if (isset($DB2))", it also not work. How i can fix it? RE: CodeIgniter 2.x and shutdown database - Rufnex - 01-14-2015 Try to check the connection by this way: PHP Code: if(false === $DB2->conn_id) RE: CodeIgniter 2.x and shutdown database - UchihaSV - 01-14-2015 I alredy understand what the problem is when looked in print_r($DB2), and i use "if ($DB2->conn_id)". |