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

search for in the

pg_select> <pg_result_seek
[edit] Last updated: Fri, 18 May 2012

view this page in

pg_result_status

(PHP 4 >= 4.2.0, PHP 5)

pg_result_status Gibt den Status eines Abfrageergebnisses zurück

Beschreibung

mixed pg_result_status ( resource $result [, int $type ] )

pg_result_status() gibt den Status eines Abfrageergebnisses zurück oder das mit dem Ergebnis verknüpfte PostgreSQL Kommando-Tag, wenn die Abfrage erfolgreich war.

Parameter-Liste

result

PostgreSQL Ergebniskennung, die (unter anderem) von den Funktionen pg_query(), pg_query_params() oder pg_execute() zurückgegeben wurde.

type

Entweder PGSQL_STATUS_LONG, um die Statusnummer von result zu erhalten, oder PGSQL_STATUS_STRING, um das PostgreSQL Kommando-Tag für das result zu erhalten. Falls nichts angegeben wurde, wird der Vorgabewert PGSQL_STATUS_LONG zurückgegeben.

Rückgabewerte

Mögliche Rückgabewerte sind PGSQL_EMPTY_QUERY, PGSQL_COMMAND_OK, PGSQL_TUPLES_OK, PGSQL_COPY_OUT, PGSQL_COPY_IN, PGSQL_BAD_RESPONSE, PGSQL_NONFATAL_ERROR und PGSQL_FATAL_ERROR, falls PGSQL_STATUS_LONG angegeben wurde. Anderenfalls wird ein string zurückgegeben, der das PostgreSQL Kommando-Tag enthält.

Changelog

Version Beschreibung
4.3.0 Der Parameter type wurde hinzugefügt.

Beispiele

Beispiel #1 pg_result_status() Beispiel

<?php

// Zur Datenbank verbinden
$conn pg_pconnect("dbname=publisher");

// Eine Abfrage ausführen
$result pg_query($conn"COPY authors FROM STDIN;");

// Den Status des Abfrageergebnisses holen
$status pg_result_status($result);

// Den Status ermitteln
if ($status == PGSQL_COPY_IN)
   echo 
"Copy begonnen.";
else
   echo 
"Copy fehlgeschlagen."
?>

Das oben gezeigte Beispiel erzeugt folgende Ausgabe:

Copy begonnen.

Siehe auch



add a note add a note User Contributed Notes pg_result_status
Meej Vaj 08-Jun-2005 06:45
If on "accident" your program passes pg_result_status a variable that is NOT a actual pg resource, it will return an empty string.
(This is important to know if you want to make sure a pg resource is "good" before attempting some operation on it).
romix at gmx dot de 16-Oct-2002 06:29
0 = PGSQL_EMPTY_QUERY
1 = PGSQL_COMMAND_OK
2 = PGSQL_TUPLES_OK
3 = PGSQL_COPY_TO
4 = PGSQL_COPY_FROM
5 = PGSQL_BAD_RESPONSE
6 = PGSQL_NONFATAL_ERROR
7 = PGSQL_FATAL_ERROR

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