PHP Doku:: Gibt den aktuellen Transaktionsstatus des Servers zurück - function.pg-transaction-status.html

Verlauf / Chronik / History: (1) anzeigen

Sie sind hier:
Doku-StartseitePHP-HandbuchFunktionsreferenzDatenbankerweiterungenAnbieterspezifische DatenbankerweiterungenPostgreSQLPostgreSQL-Funktionenpg_transaction_status

Ein Service von Reinhard Neidl - Webprogrammierung.

PostgreSQL-Funktionen

<<pg_trace

pg_tty>>

pg_transaction_status

(PHP 5 >= 5.1.0)

pg_transaction_statusGibt den aktuellen Transaktionsstatus des Servers zurück

Beschreibung

int pg_transaction_status ( resource $connection )

Gibt den aktuellen Transaktionsstatus des Servers zurück.

Achtung

Die Funktion pg_transaction_status() gibt ungültige Ergebnisse zurück, wenn sie für einen PostgreSQL-Server der Version 7.3 aufgerufen wird, bei dem der Parameter autocommit auf off gesetzt ist. Die serverseitige Eigenschaft autocommit ist veraltet und existiert in den neueren PostgreSQL-Versionen nicht mehr.

Parameter-Liste

connection

PostgreSQL-Verbindungskennung.

Rückgabewerte

Mögliche Stati sind: PGSQL_TRANSACTION_IDLE (zur Zeit untätig), PGSQL_TRANSACTION_ACTIVE (ein Kommando wird abgearbeitet), PGSQL_TRANSACTION_INTRANS (untätig, aber innerhalb eines gültigen Transaktionsblocks) oder PGSQL_TRANSACTION_INERROR (untätig, innerhalb einer fehlgeschlagenen Transaktion). PGSQL_TRANSACTION_UNKNOWN wird zurückgegeben, falls eine Transaktion ungültig ist. PGSQL_TRANSACTION_ACTIVE wird nur dann zurückgegeben, wenn eine Abfrage zum Server gesendet wurde und noch nicht fertig abgearbeitet ist.

Beispiele

Beispiel #1 pg_transaction_status()-Beispiel

<?php
  $dbconn 
pg_connect("dbname=publisher") or die("Konnte nicht verbinden");
  
$stat pg_transaction_status($dbconn);
  if (
$stat === PGSQL_TRANSACTION_UNKNOWN) {
      echo 
'Verbindung ist ungültig';
  } else if (
$stat === PGSQL_TRANSACTION_IDLE) {
      echo 
'Verbindung ist zur Zeit untätig';
  } else {
      echo 
'Verbindung meldet eine Transaktion';
  }
?>


2 BenutzerBeiträge:
- Beiträge aktualisieren...
hofman dot tomas at gmail dot com
8.07.2010 10:52
Exact values of constants:

PGSQL_TRANSACTION_IDLE = 0
PGSQL_TRANSACTION_ACTIVE = 1
PGSQL_TRANSACTION_INTRANS = 2
PGSQL_TRANSACTION_INERROR = 3
PGSQL_TRANSACTION_UNKNOWN = 4
btherl at yahoo dot com dot au
18.07.2006 4:27
This function is implemented in C, so there's no way to mimic it in SQL for older versions of PHP.  But you can mimic some of the functionality by using a wrapper which keeps track of when you begin and commit/rollback transactions.



PHP Powered Diese Seite bei php.net
The PHP manual text and comments are covered by the Creative Commons Attribution 3.0 License © the PHP Documentation Group - Impressum - mail("TO:Reinhard Neidl",...)