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

search for in the

pg_insert> <pg_get_result
[edit] Last updated: Fri, 10 Feb 2012

view this page in

pg_host

(PHP 4, PHP 5)

pg_host Zwraca nazwę komputera związanego z połączeniem

Opis

string pg_host ([ resource $polaczenie ] )

pg_host() zwraca nazwę komputera, dla danego identyfikatora polaczenie, z którym połączony jest PostgreSQL.

Parametry

polaczenie

Identyfikator połączenia do bazy PostgreSQL. Gdy parametr polaczenie nie został podany, domyślne połączenie jest używane. Domyślnym połączeniem jest ostatnie połączenie stworzone przez pg_connect() lub pg_pconnect().

Zwracane wartości

Łańcuch (ang. string) zawierający nazwę komputera, do którego polaczenie jest nawiązane, lub FALSE w razie błędu.

Przykłady

Przykład #1 pg_host() - przykład

<?php
$pgsql_polacz 
pg_connect("dbname=marek host=localhost");

if (
$pgsql_polacz) {
   print 
"Nawiązano połączenie do: " pg_host($pgsql_polacz) . "<br/>\n";
} else {
   print 
pg_last_error($pgsql_polacz);
   exit;
}
?>

Zobacz też:

  • pg_connect() - Otwiera tymczasowe połączenie do PostgreSQL-a
  • pg_pconnect() - Otwiera trwałe połączenie z serwerem PostgreSQL



add a note add a note User Contributed Notes pg_host
mark at redbrick dot dcu dot ie 24-Mar-2003 06:21
This is a simple example of this function, which returns the name of which PostreSQL Database you are currently connected to.

<?php
    $pgsql_conn
= pg_connect("dbname=mark host=localhost");

    if (
$pgsql_conn) {
        print
"Successfully connected to: " . pg_host($pgsql_conn) . "<br/>\n";
    } else {
        print
pg_last_error($pgsql_conn);
        exit;
    }
?>

This function is extremely useful for sites which connect to multiple Postgresql services.

Regards,  --mark

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