(PHP 4 >= 4.3.0, PHP 5, PHP 7)
pg_fetch_assoc — 锟斤拷取一锟斤拷锟斤拷为锟斤拷锟斤拷锟斤拷锟斤拷
$result
[, int $row
] ) : arraypg_fetch_assoc() 锟酵碉拷锟斤拷 pg_fetch_array() 锟斤拷锟较碉拷锟斤拷锟斤拷锟斤拷选锟斤拷锟斤拷 PGSQL_ASSOC 锟角等价的★拷锟斤拷只锟斤拷锟斤拷一锟斤拷锟斤拷锟斤拷锟斤拷锟介。锟斤拷锟斤拷锟揭拷锟斤拷锟斤拷锟斤拷锟斤拷锟斤拷锟� pg_fetch_row()锟斤拷
pg_fetch_assoc() 锟斤拷 pg_fetch_row() 锟斤拷锟斤拷展锟芥本锟斤拷锟斤拷锟剿斤拷锟斤拷锟捷存储锟斤拷锟斤拷锟斤拷锟斤拷锟斤拷锟斤拷锟街段憋拷牛锟街拷猓拷匣锟斤拷锟斤拷锟斤拷锟芥储锟节癸拷锟斤拷锟斤拷锟斤拷锟斤拷锟街讹拷锟斤拷锟斤拷锟叫★拷
row
锟斤拷要锟斤拷锟斤拷取锟斤拷锟叫o拷锟斤拷录锟斤拷锟斤拷拧锟斤拷锟揭伙拷锟轿� 0锟斤拷
pg_fetch_assoc() 锟斤拷锟斤拷锟斤拷锟皆憋拷 pg_fetch_row() 锟斤拷锟斤拷锟斤拷锟揭伙拷锟斤拷锟斤拷锟斤拷锟斤拷锟斤拷使锟矫★拷
Example #1 pg_fetch_assoc() 锟斤拷锟斤拷
<?php
$conn = pg_pconnect("dbname=publisher");
if (!$conn) {
echo "An error occured.\n";
exit;
}
$result = pg_query($conn, "SELECT id, author, email FROM authors");
if (!$result) {
echo "An error occured.\n";
exit;
}
while ($row = pg_fetch_assoc($result)) {
echo $row['id'];
echo $row['author'];
echo $row['email'];
}
?>
锟轿硷拷 pg_fetch_row()锟斤拷pg_fetch_array()锟斤拷pg_fetch_object() 锟斤拷 pg_fetch_result()锟斤拷