I have following in my config.php file for one of my web app.
//db settings
$host = 'localhost'; //database location
$user = 'example'; //database username
$pass = 'example12'; //database password
$db_name = 'example'; //database name
//create db connection
$link = mysql_connect($host, $user, $pass);
mysql_select_db($db_name);
//sets encoding to utf8
mysql_query("SET NAMES utf8");
I am including config.php
in all pages of my application at top (1st line of code).
I want to know that will PHP/MYSQL maintain connection open and close automatically or I need to explicitly call them. Connection is opening by itself, as I am doing all db based tasks properly. But not closing connection anywhere, this is a high traffic website.
Please correct me if I am wrong anywhere.
Thanks!