Codeigniter ignoring $this->db->close() ? - 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: Codeigniter ignoring $this->db->close() ? (/showthread.php?tid=40840) |
Codeigniter ignoring $this->db->close() ? - El Forum - 04-20-2011 [eluser]fiat[/eluser] Hi There, I'm having trouble with a database connection persisting even thou i call $this->db->close(); Below is my code Code: $beach_name = $this->Slsa_model->getBeachName($this->uri->segment(3)); Model Code: function getBeachName($beach_key) Now the issue is, when I try to perform the INSERT into POSTGRES database, i get the error message saying Code: ERROR: relation "beach" does not exist at character 13 After a bit of scratching around, it seems the insert is trying to apply to the ABSAMP database, not the POSTGRES Why would this connection be persisting even thou I have closed the DB connection? Codeigniter ignoring $this->db->close() ? - El Forum - 04-20-2011 [eluser]danmontgomery[/eluser] IIRC it's because of the way CI handles loading. Even if the database is closed, the $this->database variable isn't unset, so the database isn't reloaded, even though you specify a different one. You should be able to get around it with: Code: $this->db = $this->load->database('absamp', TRUE); Although, because they're separate databases I would probably separate them. Code: $this->_db = $this->load->database('absamp', TRUE); Codeigniter ignoring $this->db->close() ? - El Forum - 04-20-2011 [eluser]fiat[/eluser] Thanks for the quick reply, your fix resolved the issue perfectly. So, does this count as a bug? Codeigniter ignoring $this->db->close() ? - El Forum - 04-20-2011 [eluser]danmontgomery[/eluser] Probably not... There's no clean way to "unload" anything in CI. |