title: Check if database exists in postgreSQL using PHP
body: <p>I was wondering if anyone would be able to tell me about whether it is possible to use PHP to check if a postgresql database exists?</p>
  
  <p>I am writing a PHP script and I only want it to create the database if it doesn't already exist but up to now haven't been able to see how to implement it.</p>
  
  <p>Thank you</p>
  
  <hr>
  
  <p>I've tried </p>
  
  <pre><code>$cmd = 'psql -U postgres -c "SELECT schema_name FROM information_schema.schemata WHERE schema_name = 'portal';"';
      exec($cmd);
  </code></pre>
  
  <p>I got </p>
  
  <pre><code>PHP Parse error:  syntax error, unexpected 'portal'
  </code></pre>