Heim  >  Artikel  >  Backend-Entwicklung  >  php连接与操作PostgreSQL数据库的方法_PHP

php连接与操作PostgreSQL数据库的方法_PHP

WBOY
WBOYOriginal
2016-06-01 11:06:36811Durchsuche

本文实例讲述了php连接与操作PostgreSQL数据库的方法。分享给大家供大家参考。

具体实现方法如下:

代码如下:


$pg=@pg_connect("host=localhost user=postgres password=sa dbname=employes")
or die("can't connect to database.");
$query="select * from employes order by serial_no";
//$query="insert into employes values(10008,'susan','1985-09-04','80','50')";
$result=@pg_query($pg,$query) or die("can't run query to table.");
//echo pg_num_rows($result); //输出多少条记录被查询
//if($result)
//{
//echo "recrods inserted sucessfully!";
//echo pg_affected_rows($result);//输出多少条记录被插入
/

Stellungnahme:
Der Inhalt dieses Artikels wird freiwillig von Internetnutzern beigesteuert und das Urheberrecht liegt beim ursprünglichen Autor. Diese Website übernimmt keine entsprechende rechtliche Verantwortung. Wenn Sie Inhalte finden, bei denen der Verdacht eines Plagiats oder einer Rechtsverletzung besteht, wenden Sie sich bitte an admin@php.cn