When I open a MySQL connection in PHP with just PHP's built-in MySQL functions, I do the following:
$link = mysql_connect($servername,$username,$password);
mysql_select_db($dbname);
//queries etc.
mysql_close($link);
When I open a connection with PDO, it looks like this:
$link = new PDO("mysql:dbname=$dbname;host=$servername",$username,$password);
//prepare statements, perform queries
Do I have to explicitly close the connection like I do with mysql_connect()
and mysql__close()
? If not, how does PHP know when I'm done with my connection?
TIA.