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?
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.
Thank you
I've tried
$cmd = 'psql -U postgres -c "SELECT schema_name FROM information_schema.schemata WHERE schema_name = 'portal';"';
exec($cmd);
I got
PHP Parse error: syntax error, unexpected 'portal'
\'portal\'... but why are you using an exec rather than something like pdo?