最新国产好看的视频,伊人天堂AV在线,国产Aaaaaa视频,蜜臀视频在线观看一区,人妻av色图,密臀久久久精品影片,青青视频免费观看毛片,久草在线观看视,国产三级精品色情在线

php連接與操作PostgreSQL數(shù)據(jù)庫的方法

 更新時間:2014年12月25日 08:58:19   投稿:shichen2014  
這篇文章主要介紹了php連接與操作PostgreSQL數(shù)據(jù)庫的方法,以實例形式較為詳細的分析了php連接PostgreSQL數(shù)據(jù)庫以及進行讀取與增加、修改、刪除等技巧,具有一定的參考借鑒價值,需要的朋友可以參考下

本文實例講述了php連接與操作PostgreSQL數(shù)據(jù)庫的方法。分享給大家供大家參考。

具體實現(xiàn)方法如下:

復制代碼 代碼如下:

$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程序設計有所幫助。

相關文章

最新評論

西平县| 湾仔区| 中山市| 社会| 平远县| 平度市| 浪卡子县| 双城市| 武山县| 常山县| 金山区| 民县| 阳山县| 句容市| 新昌县| 通州市| 江津市| 汾西县| 固安县| 璧山县| 日照市| 昌邑市| 巴彦县| 达日县| 周至县| 赤城县| 中山市| 威远县| 盐城市| 渝北区| 宁都县| 陈巴尔虎旗| 临朐县| 积石山| 大竹县| 马龙县| 伊春市| 辉南县| 内乡县| 大石桥市| 汕头市|