title: Open and close connection to db or keep it
body: <p>I have seen a lot of answers regarding <code>.NET</code> and <code>C#</code> applications, but I didn't find what I was looking for about Web ones (or else I didn't search well and I apologize for it).</p>
  
  <p>My question is about connections to database during queries : Should I open and close a connection each query I am doing or should I create one and keep it all long ?<br/>
  I guess it's the first one, but I want some informations about the differences between both regarding <b>Performance</b> and <b>Security</b>.</p>
  
  <p>Moreover, is this enough to close a connection :</p>
  
  <pre><code>$dbh = new PDO('mysql:host=localhost;dbname=foo', '', '')
  // queries
  $dbh = null;
  </code></pre>