Comunitatea PHP Romania
 

 
pg_fetch_assoc

pg_fetch_assoc

(PHP 4 >= 4.3.0, PHP 5)

pg_fetch_assoc -- Fetch a row as an associative array

Description

array pg_fetch_assoc ( resource result [, int row])

pg_fetch_assoc() returns an associative array that corresponds to the fetched row (tuples/records). It returns FALSE, if there are no more rows.

pg_fetch_assoc() is equivalent to calling pg_fetch_array() with PGSQL_ASSOC for the optional third parameter. It only returns an associative array. If you need the numeric indices, use pg_fetch_row().

row is row (record) number to be retrieved. First row is 0.

pg_fetch_assoc() is NOT significantly slower than using pg_fetch_row(), while it provides a significant ease of use.

Exemplu 1. pg_fetch_assoc() example

<?php
$conn
= pg_connect("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'];
}
?>

See also pg_fetch_row(), pg_fetch_array(), pg_fetch_object() and pg_fetch_result().

Ultimele discutii in forum RSS Forum

Ultimele articole Ultimele articole

Top membri

Pirahna Pirahna
la birou
carco carco
Bucuresti
Birkoff Birkoff
Bucuresti
Mascka Mascka
Braila
raul_ raul_
whooper whooper
Toronto ON
mihaitha mihaitha
Sibiu
gabysolomon gabysolomon
Bacau
oriceon oriceon
Constanta
garlicinicolae garlicinicolae

Newsletter


Email:
 inscriere
 renuntare
 
 Arhiva newsletter

Parteneriat

Copyright © 2001-2008 PHP Romania Add PHPRomania to Google Add PHPRomania to Del.icio.us Add PHPRomania to Stumbleupon Add PHPRomania to Yahoo! Add PHPRomania to Digg Add PHPRomania to Blink Libros de historia | Debt Consolidation | Crude Oil Futures | Mortgage Calculator | Mortgage Loans
Ads: Partener Way2Web Nework: gazduire web | inregistrare domenii | web design | imobiliare | web hosting
Powered by Simplis