title: Create Database If Not Exists with PDO
body: <p>I'm trying to create a database-install PHP file that first attempts to create a database if it does not already exist using a PDO prepared statement that I execute, and then I would like to connect to this. Is this how I would do it? Or is there something I'm missing here?</p>
  
  <pre><code>$mysql = new PDO("mysql:host=localhost", $dbusername, $dbpassword);
  $pstatement = $mysql-&gt;prepare("CREATE DATABASE IF NOT EXISTS $dbname");
  $pstatment-&gt;execute();
  $dbconn = new PDO("mysql:host=localhost;dbname=$dbname", $dbusername, $dbpassword);
  </code></pre>