PHP: pg_field_type - Manual

downloads | documentation | faq | getting help | mailing lists | reporting bugs | php.net sites | links | conferences | my php.net

search for in the

pg_free_result pg_field_type_oid

Last updated: Sat, 27 Jan 2007

view this page in

# pg_field_type

(PHP 4 >= 4.2.0, PHP 5)

pg_field_type -- Returns the type name for the corresponding field number

## Описание

string pg_field_type ( resource result, int field_number )

pg_field_type() returns a string containing the base type name of the given `field_number` in the given PostgreSQL `result` resource.

> Замечание: If the field uses a PostgreSQL domain (rather than a basic type), it is the name of the domain's underlying type that is returned, rather than the name of the domain itself.

> Замечание: This function used to be called pg_fieldtype().

## Список параметров

`result`

  PostgreSQL query result resource, returned by pg_query(), pg_query_params() or pg_execute() (among others).

`field_number`

  Field number, starting from 0.

## Возвращаемые значения

A string containing the base name of the field's type, or `FALSE` on error.

## Примеры

Пример 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: ", pg_field_type($res, 0);
?>`

Результат выполнения данного примера:

    Title field type: varchar

## Смотрите также

pg_field_prtlen()
pg_field_name()
pg_field_type_oid()

add a note User Contributed Notes
pg_field_type
marxarelli
02-Jan-2006 02:34
`Because complete documentation is always helpful, here are all the PostgreSQL general purpose types as they are listed in the 8.1 documentation, and each corresponding string returned by pg_field_type().
bigint => int8
bigserial => int8
bit => bit
bit varying => varbit
boolean => bool
box => box
bytea => bytea
character varying => varchar
character => bpchar
cidr => cidr
circle => circle
date => date
double precision => float8
inet => inet
integer => int4
interval => interval
line => line
lseg => lseg
macaddr => macaddr
money => money
numeric => numeric
path => path
point => point
polygon => polygon
real => float4
smallint => int2
serial => int4
text => text
time => time
time with time zone => timetz
timestamp => timestamp
timestamp with time zone => timestamptz
And for the record... (note the 7.4 client lib)
# postmaster --version
postmaster (PostgreSQL) 8.0.4
# ldd libphp4.so
...
libpq.so.3 => /usr/lib/libpq.so.3 (0xb7ac8000)
...`
andy at a 2 h d dot com
03-May-2003 12:09
`The types returned are:
bool
int2 (smallint)
int4
int8 (bigint)
numeric
float4 (real / float)
float8 (double)
timestamp
date
time
varchar
bpchar (fixed leng string, 'blank padded char')
inet (ip address)
money
There are some other more esoteric types, e.g. 'circle', but these are the most common.`
add a note
pg_free_result pg_field_type_oid

Last updated: Sat, 27 Jan 2007
show source | credits | stats | sitemap | contact | advertising | mirror sites
Copyright © 2001-2007 The PHP Group
All rights reserved.
This mirror generously provided by: Yahoo! Inc.
Last updated: Sat Mar 10 10:36:09 2007 PST