i have a few question on php db connection and hoping someone can answer them all, when i create a db connection using pdo, like below
<?php
/* Connect to an ODBC database using driver invocation */
$dsn = 'mysql:dbname=testdb;host=127.0.0.1';
$user = 'dbuser';
$password = 'dbpass';
try {
$dbh = new PDO($dsn, $user, $password);
} catch (PDOException $e) {
echo 'Connection failed: ' . $e->getMessage();
}
?>
- is this connection always created when someone refreshes the php page?
- or does it check if that connection is already open and then use that connection instead?
- how would i be able to close that connection when i am done with it?