CodeIgniter Forums
Does Codeigniter automatically close the database connection - 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: Does Codeigniter automatically close the database connection (/showthread.php?tid=66411)



Does Codeigniter automatically close the database connection - kumarg311 - 10-20-2016

Hi ,

I want to know Does Codeigniter automatically close the database connection or we have close manually.
If it  close the database connection automatically , where  can i check this code .


RE: Does Codeigniter automatically close the database connection - Compra Venta Cuba - 10-20-2016

Good question.

I have made this MY_Model located at "core" folder and extends all my models to this.

class MY_Model extends CI_Model
{

/**
* MY_Model constructor.
*/
public function __construct()
{
parent::__construct();
}

public function __destruct()
{
$this->db->close();
}

}


RE: Does Codeigniter automatically close the database connection - InsiteFX - 10-20-2016

Manually closing the Connection


RE: Does Codeigniter automatically close the database connection - Narf - 10-21-2016

You don't need to.

During shutdown, PHP itself closes any resources that haven't been closed.