我需要连接到提供一些凭据的PostgreSQL server,并为给定用户打印该主机上可用数据库的列表.
我正在努力:
<?php
$connection = pg_connect("host=localhost user=testuser password=123 connect_timeout=5");
?>
我得到:
Warning: pg_connect() [function.pg-connect]: Unable to connect to PostgreSQL server: FATAL: database "testuser" does not exist in /var/www/test.php on line 56
我认为这一定是可能的,因为phpPgAdmin做到了这一点,但我查看了phpPpAdmin源代码,发现它们连接到一个名为template1
的数据库.
从http://www.postgresql.org/docs/8.1/interactive/manage-ag-templatedbs.html开始:
"创建数据库"实际上是通过复制现有数据库来工作的.通过
有没有一种不指定任何数据库的连接方式?