国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 開發 > PHP > 正文

php連接與操作PostgreSQL數據庫的方法

2024-05-04 23:29:22
字體:
來源:轉載
供稿:網友
這篇文章主要介紹了php連接與操作PostgreSQL數據庫的方法,以實例形式較為詳細的分析了php連接PostgreSQL數據庫以及進行讀取與增加、修改、刪除等技巧,具有一定的參考借鑒價值,需要的朋友可以參考下
 
 

本文實例講述了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);//輸出多少條記錄被插入 
//} 
//實例一[pg_fetch_row] 
echo "<table border=1>"; 
echo "<tr>"; 
echo "<td>serial_no</td>"; 
echo"<td>name</td>"; 
echo"<td>birthday</td>"; 
echo"</tr>"; 
for($i=0;$i<pg_num_rows($result);$i++) 

$row=@pg_fetch_row($result) or die("can't fetch row from table."); 
$serial_no= $row[0]; 
$name= $row[1]; 
$birthday= $row[2]; 
echo"<tr>"; 
echo"<td>$serial_no</td>"; 
echo"<td>$name</td>"; 
echo"<td>$birthday</td>"; 
echo"</tr>"; 

echo"</table>"; 
//實例二[pg_fetch_array] 
//echo "<table border=1>"; 
//echo "<tr>"; 
//echo "<td>serial_no</td>"; 
//echo"<td>name</td>"; 
//echo"<td>birthday</td>"; 
//echo"</tr>"; 
// 
//for($i=0;$i<pg_num_rows($result);$i++) 
//{ 
// 
//$row=@pg_fetch_array($result) or die("can't fetch row from table."); 
//$serial_no= $row['serial_no']; 
//$name= $row['name']; 
//$birthday= $row['birthday']; 
//echo"<tr>"; 
//echo"<td>$serial_no</td>"; 
//echo"<td>$name</td>"; 
//echo"<td>$birthday</td>"; 
//echo"</tr>"; 
// 
//} 
//echo"</table>"; 
//增加,刪除,修改實例 
//$newrow=array("serial_no"=>"1006","name"=>"peter","birthday"=>"1990-07-03","salary"=>"90","bonus"=>"80"); 
//$reusult=@pg_insert($pg,"employes",$newrow) or die("can't insert data to table.");
//if($reusult) 
//{ 
//echo "rechords inserted sucessfully!"; 
//} 
// 
pg_close($pg);

 

希望本文所述對大家的PHP程序設計有所幫助。


發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 古田县| 周宁县| 金门县| 大冶市| 四川省| 廉江市| 颍上县| 乡宁县| 雷山县| 华容县| 安泽县| 仁寿县| 平谷区| 隆回县| 肥东县| 芜湖县| 福海县| 上思县| 当阳市| 施甸县| 比如县| 民县| 长兴县| 敦煌市| 富阳市| 华蓥市| 商都县| 东至县| 高唐县| 上高县| 潢川县| 广德县| 古交市| 武邑县| 云龙县| 镇平县| 舟曲县| 怀来县| 清苑县| 司法| 长治市|