Htaccess    html   Php    javascript   Asp   css    maths  Past Questions  Practice Tests Online

pg fetch array function syntax tag tutorial 2013 Donate at flattr Flattr this





Alert! Connect with 10,000 Chating Online. Join Now

Php pg fetch array () function

Write your php code

 
<?php ?>

Php Result


Your code below



(PHP 3>= 3.0.1, PHP 4 , PHP 5)

pg_fetch_array -- Fetch a row as an array

Syntax

array pg_fetch_array ( resource result [, int row [, int result_type]] )

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

pg_fetch_array() is an extended version of pg_fetch_row(). In addition to storing the data in the numeric indices (field index) to the result array, it also stores the data in associative indices (field name) by default.

Note: This function sets NULL fields to PHP NULL value.

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

result_type is an optional parameter that controls how the return value is initialized. result_type is a constant and can take the following values: PGSQL_ASSOC, PGSQL_NUM, and PGSQL_BOTH. Using PGSQL_NUM, pg_fetch_array() will return an array with numerical indices, using PGSQL_ASSOC will return only associative indices while PGSQL_BOTH, the default, will return both numerical and associative indices.

Note: result_type was added in PHP 4.0.

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

Note: From 4.1.0, row became optional. Calling pg_fetch_array() will increment the internal row counter by one.

Examples

Example 1. pg_fetch_array() example

<?php

$conn
= pg_pconnect("dbname=publisher");
if (!
$conn) {
  echo
"An error occured.\n";
  exit;
}

$result = pg_query($conn, "SELECT author, email FROM authors");
if (!
$result) {
  echo
"An error occured.\n";
  exit;
}

$arr = pg_fetch_array($result, 0, PGSQL_NUM);
echo
$arr[0] . " <- Row 1 Author\n";
echo
$arr[1] . " <- Row 1 E-mail\n";

// As of PHP 4.1.0, the row parameter is optional; NULL can be passed instead,
// to pass a result_type.  Successive calls to pg_fetch_array will return the
// next row.
$arr = pg_fetch_array($result, NULL, PGSQL_ASSOC);
echo
$arr["author"] . " <- Row 2 Author\n";
echo
$arr["email"] . " <- Row 2 E-mail\n";

$arr = pg_fetch_array($result);
echo
$arr["author"] . " <- Row 3 Author\n";
echo
$arr[1] . " <- Row 3 E-mail\n";

?>

Php pg fetch array Function syntax tag

pg fetch array php code on this is provided for your study purpose, it will guide you to know how create and design a website using php. use it to practice and train your self online



Php pg fetch array syntax tutorial

php tutorial guide and code design are for easy learning and programming. The code practice section provided at the top is for practising of this syntax. Use the code section up to practice your php programming online. Learning php is very easy, all you need is to use the examples on this site and practice them to perfect your skills.


Function index

Variables

Expressions

Operators

Control-Structures

Cookies

Array

Date & Time

Directory function

File

Image

Operators

Form data handling

Mathematics operators

Mail

Php Mysql

Network Functions

Strings

php tutorial guides,functions, classes, code examples and tags for creating simple dynamic site to mysql database driven sites
 
 
Htaccess    html   Php    javascript   Asp   css    maths  Past Questions  Practice Tests Online