origin2017序列号:php怎样与postgres连接

来源:百度文库 编辑:查人人中国名人网 时间:2024/04/30 01:09:09
哪位知道的大人给出具体的连接方法吧!万分感谢!最好是linux环境下的

windows环境下是这样:
1系统目录下(WINDOWS),php.ini文件中,把extension=php_pgsql.dll这句的注释去掉。

2 检索找到php_pgsql.dll文件所在目录(在***\php\ext)。

3 在php.ini中的extension_dir处指定php_pgsql.dll所在目录。(为了方便,直接把这个文件复制到php.ini同级目录下,直接写extension_dir = "./")

4 Test页面postgres.php:
<html>
<body>
<div align="center">
test for postgres
<br>
<?
$dbconn = pg_connect("host=*** port=**** dbname=*** user=postgres password=");
if($dbconn)
{
echo "the database is connected";
}else
{
echo "the databse isn't connected";
}
?>

</div>
</body>
<html>

5 在IE地址栏中输入:http://127.0.0.1/postgres.php
显示:
test for postgres
the database is connected
连接成功。

相关sql操作可参考:
http://machine.ustc.edu.cn/ch_doc/php/ref.pgsql.php.htm