PG_FIELD_NUM(3)PG_FIELD_NUM(3)pg_field_num - Returns the field number of the named fieldSYNOPSIS
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_TYPE_OID(3)PG_FIELD_TYPE_OID(3)pg_field_type_oid - Returns the type ID (OID) for the corresponding field numberSYNOPSIS
int pg_field_type_oid (resource $result, int $field_number)
DESCRIPTION pg_field_type_oid(3) returns an integer containing the OID of the base type of the given $field_number in the given PostgreSQL $result
resource.
You can get more information about the field type by querying PostgreSQL's pg_type system table using the OID obtained with this function.
The PostgreSQL format_type(3) function will convert a type OID into an SQL standard type name.
Note
If the field uses a PostgreSQL domain (rather than a basic type), it is the OID of the domain's underlying type that is returned,
rather than the OID of the domain itself.
PARAMETERS
o $result
- PostgreSQL query result resource, returned by pg_query(3), pg_query_params(3) or pg_execute(3) (among others).
o $field_number
- Field number, starting from 0.
RETURN VALUES
The OID of the field's base type. FALSE is returned on error.
EXAMPLES
Example #1
Getting information about fields
<?php
$dbconn = pg_connect("dbname=publisher") or die("Could not connect");
// Assume 'title' is a varchar type
$res = pg_query($dbconn, "select title from authors where author = 'Orwell'");
echo "Title field type OID: ", pg_field_type_oid($res, 0);
?>
The above example will output:
Title field type OID: 1043
SEE ALSO pg_field_type(3), pg_field_prtlen(3), pg_field_name(3).
PHP Documentation Group PG_FIELD_TYPE_OID(3)
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)
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)
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)
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)
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)
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)
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)
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)