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

search for in the

pg_free_result> <pg_field_type_oid
[edit] Last updated: Fri, 23 Mar 2012

view this page in

pg_field_type

(PHP 4 >= 4.2.0, PHP 5)

pg_field_type Zwraca typ wskazanej kolumny

Opis

string pg_field_type ( resource $wynik , int $numer_kolumny )

pg_field_type() zwraca łańcuch zawierający typ podstawowy kolumny wskazanej przez numer_kolumny w wyniku wynik PostgreSQL-a.

Informacja:

Jeśli kolumna używa domeny PostgreSQL (zamiast typu podstawowego), jest to nazwa podstawowego typu domeny, który jest zwrócony, zamiast nazwy samej domeny.

Informacja:

Ta funkcja dawniej nazywała się pg_fieldtype().

Parametry

wynik

Identyfikator wyniku zapytania do bazy PostgreSQL, zwrócony przez funkcję pg_query(), pg_query_params() lub pg_execute() (między innymi).

numer_pola

Numer pola, zaczynając od zera.

Zwracane wartości

Łańcuch (ang. string) zawierający podstawową nazwę typu pola, lub FALSE w przypadku błędu.

Przykłady

Przykład #1 Pobieranie informacji o kolumnach

<?php
  $polaczenie_do_bazy 
pg_connect("dbname=publisher") or die("Nie można się połączyć");

  
// Załóżmy, że 'tytul' jest typu varchar
  
$res pg_query($polaczenie_do_bazy"select tytul from autorzy where autor = 'Orwell'");

  echo 
"Typ pola tytułu: "pg_field_type($res0);
?>

Powyższy przykład wyświetli:

Typ pola tytułu: varchar

Zobacz też:



pg_free_result> <pg_field_type_oid
[edit] Last updated: Fri, 23 Mar 2012
 
add a note add a note User Contributed Notes pg_field_type
Anonymous 16-Jan-2010 07:18
Also be aware that postgreSQL array fields will prefix the type name with an underscore (e.g. "_int4" or "_text"), while composite a.k.a. row-type fields will return type "record".
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.

 
show source | credits | stats | sitemap | contact | advertising | mirror sites