Reputation: 792
As per my knowledge, if I connect MySQL
, I have to close the connection immediately after executing the script otherwise it will stay opened.
My question is does codeigniter
close the MySQL
connection each time after executing the script? If not, how do I perform it ?
Upvotes: 1
Views: 852
Reputation: 674
Codeigniter closes its database connection. But to manually do that within your class you can use the following
$this->db->close();
Read here for more information https://www.codeigniter.com/user_guide/database/connecting.html
Upvotes: 1
Reputation: 5398
Yes Codeigniter close connection automatically as said in manual http://www.codeigniter.com/user_guide/database/connecting.html#manually-closing-the-connection
But if you want to close explicitly you can
$this->db->close();
Upvotes: 1
Reputation: 137
It should do yes. But its good practice to close it any way.
$connect->close();
$connect being:
$connect = new mysqli($servername, $username, $password, $dbname);
Upvotes: 0