仅作参考,具体的写法每个人有每个人的习惯。
// PostgreSQL Connect
if (!($cn = pg_connect("host=sak-design port=5432 dbname=sak user=sak password=sak")))
{
die('接続失敗です。'.pg_last_error());
}
// PostgreSQL Select
$sql = "select * from testm";
if (!($rs = pg_exec($sql)))
{
die; }
// PostgreSQL Get Records
$ct = pg_numrows($rs);
for ($i = 0; $i < $ct; $i++)
{
$item = pg_fetch_array($rs, $i);
print "${item[0]} ";
print "${item[1]} ";
print "${item['value1']} ";
print "${item['value2']}
";
}
// PostgreSQL Disconnect
pg_close($cn);
// End
?>
阅读(517) | 评论(0) | 转发(0) |