Linux and UNIX Man Pages

Linux & Unix Commands - Search Man Pages

pg_field_num(3) [php man page]

PG_FIELD_NUM(3) 														   PG_FIELD_NUM(3)

pg_field_num - Returns the field number of the named field

SYNOPSIS
int pg_field_num (resource $result, string $field_name) DESCRIPTION
pg_field_num(3) will return the number of the field number that corresponds to the $field_name in the given PostgreSQL $result resource. Note This function used to be called pg_fieldnum(3). PARAMETERS
o $result - PostgreSQL query result resource, returned by pg_query(3), pg_query_params(3) or pg_execute(3) (among others). o $field_name - The name of the field. RETURN VALUES
The field number (numbered from 0), or -1 on error. EXAMPLES
Example #1 Getting information about fields <?php $dbconn = pg_connect("dbname=publisher") or die("Could not connect"); $res = pg_query($dbconn, "select author, year, title from authors where author = 'Orwell'"); echo "Column 'title' is field number: ", pg_field_num($res, 'title'); ?> The above example will output: Column 'title' is field number: 2 SEE ALSO
pg_field_name(3). PHP Documentation Group PG_FIELD_NUM(3)

Check Out this Related Man Page

PG_FIELD_IS_NULL(3)													       PG_FIELD_IS_NULL(3)

pg_field_is_null - Test if a field is SQL NULL

SYNOPSIS
int pg_field_is_null (resource $result, int $row, mixed $field) DESCRIPTION
int pg_field_is_null (resource $result, mixed $field) pg_field_is_null(3) tests if a field in a PostgreSQL result resource is SQL NULL or not. Note This function used to be called pg_fieldisnull(3). PARAMETERS
o $result - PostgreSQL query result resource, returned by pg_query(3), pg_query_params(3) or pg_execute(3) (among others). o $row - Row number in result to fetch. Rows are numbered from 0 upwards. If omitted, current row is fetched. o $field - Field number (starting from 0) as an integer or the field name as a string. RETURN VALUES
Returns 1 if the field in the given row is SQL NULL, 0 if not. FALSE is returned if the row is out of range, or upon any other error. EXAMPLES
Example #1 pg_field_is_null(3) example <?php $dbconn = pg_connect("dbname=publisher") or die ("Could not connect"); $res = pg_query($dbconn, "select * from authors where author = 'Orwell'"); if ($res) { if (pg_field_is_null($res, 0, "year") == 1) { echo "The value of the field year is null. "; } if (pg_field_is_null($res, 0, "year") == 0) { echo "The value of the field year is not null. "; } } ?> PHP Documentation Group PG_FIELD_IS_NULL(3)
Man Page

8 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

How to pad spaces

Hello, I have to write a function to input a Label and a number, and output a line as the following format: Column 1 to 30: field label, left justified. Column 31 to 45: A number, right justified. The middle is padded with space. May I know how can I achieve this? (I don't know how to count... (3 Replies)
Discussion started by: sarahho
3 Replies

2. UNIX for Advanced & Expert Users

to do with awk

Hallo All, this is my code below. The problem happens under section A because field $9 sometimes does not contain a number it contains a ( and a number is contained in field $10 as result under sectionC we get a syntax error @ echo "scale=1; $aa+$ee+$ff"|bc > /tmp/pax/c3.txt So i need to choose... (1 Reply)
Discussion started by: kekanap
1 Replies

3. Shell Programming and Scripting

help with this one please

Hallo All, this is my code below. The problem happens under section A because field $9 sometimes does not contain a number it contains a (:) and a number is contained in field $10 as result under sectionC we get a syntax error @ echo "scale=1; $aa+$ee+$ff"|bc > /tmp/pax/c3.txt So i need to... (5 Replies)
Discussion started by: kekanap
5 Replies

4. UNIX for Dummies Questions & Answers

Column query

Hi all, I have a data in a script like this. First coloumn Second coloumn Third Coloumn A*****************C****************D *****************B****************E L****************M****************N ... (4 Replies)
Discussion started by: navjotmannan
4 Replies

5. Shell Programming and Scripting

Finding Nth Column

Please help me how can I display every nth field present in a "|" delimited file. Ex: If a have a file with data as a|b|c|d|e|f|g|h|k|l|m|n I want to display every 3rd feild which means the output should be c f k n Please help me. (1 Reply)
Discussion started by: ngkumar
1 Replies

6. IP Networking

duration1 and duration2 ...

Hi, My Query ::: In attached file -- Column 1 is duration1 and column2 having a field duration2 ... I want fields having duration1 > 3600 ,with corresponding duration2 .. output of two fields should be like this only --- duration1 duration2 4209 4209 Note: Few other... (2 Replies)
Discussion started by: madhur08
2 Replies

7. Shell Programming and Scripting

Putting values into order in a field using awk

Hi, I am using UBUNTU 12.04. I have a dataset as follows: Column#1 Column#2 Column#3 .... Column#50 1 154878 1 145145 2 189565 2 454121 ... (5 Replies)
Discussion started by: Homa
5 Replies

8. Shell Programming and Scripting

Assigning Column Values to ARRAY in ksh

Hi , i have file which is having two fields in it (#delimited) ABC#FILE_01.DAT DEF#FILE_02.DAT i want to write first field values to one array example A_01 and second field values to B_02 array please let me know how to do this ,my final requirement i have send out a mail for each record... (2 Replies)
Discussion started by: kkabc789
2 Replies