国产探花免费观看_亚洲丰满少妇自慰呻吟_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程序設計有所幫助。


發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 隆安县| 易门县| 台南县| 孟州市| 江永县| 桐城市| 涿鹿县| 衡阳县| 石景山区| 阿坝县| 家居| 新宾| 融水| 左贡县| 通江县| 临颍县| 遂宁市| 蕉岭县| 遂平县| 米脂县| 江安县| 蒲江县| 鄂伦春自治旗| 房山区| 宾川县| 四平市| 六枝特区| 麟游县| 千阳县| 钟山县| 大英县| 乳山市| 灌云县| 旬邑县| 永嘉县| 东辽县| 罗源县| 安陆市| 光山县| 邛崃市| 合川市|