我想知道是否有人能够告诉我是否可以使用PHP来检查postgresql数据库是否存在?
我正在编写一个PHP脚本,我只希望它创建数据库,如果它尚不存在,但到目前为止还没有看到如何实现它。
谢谢
我试过了
$cmd = 'psql -U postgres -c "SELECT schema_name FROM information_schema.schemata WHERE schema_name = 'portal';"';
exec($cmd);
我有
PHP Parse error: syntax error, unexpected 'portal'
这是一个PHP错误,你必须逃脱'\'门户'''