When I open a MySQL connection in PHP using the built-in MySQL MySQL functions, I do the following:
$link = mysql_connect($servername, $username, $password); mysql_select_db($dbname); //queries etcetera mysql_close($link);
When I open a connection to PDO, it looks like this:
$link = new PDO("mysql:dbname=$dbname;host=$servername",$username,$password); //prepare statements, perform queries
Should I explicitly close the connection, as I do with mysql_connect() and mysql_close() ? If not, how does PHP know when I ended up with my connection?
TIA.
sql php mysql pdo
benjy Jun 25 '09 at 22:57 2009-06-25 22:57
source share