PHP.nl

pg_transaction_status

pg_transaction_status

Returns the current in-transaction status of the server

int **pg_transaction_status** PgSql\Connection $connection

Returns the current in-transaction status of the server.

Let op: > will give incorrect results when using a PostgreSQL 7.3 server that has the parameter set to off. The server-side autocommit feature has been deprecated and does not exist in later server versions. pg_transaction_status``autocommit

connection

The status can be (currently idle), (a command is in progress), (idle, in a valid transaction block), or (idle, in a failed transaction block). is reported if the connection is bad. is reported only when a query has been sent to the server and not yet completed. PGSQL_TRANSACTION_IDLE``PGSQL_TRANSACTION_ACTIVE``PGSQL_TRANSACTION_INTRANS``PGSQL_TRANSACTION_INERROR``PGSQL_TRANSACTION_UNKNOWN``PGSQL_TRANSACTION_ACTIVE

Voorbeeld: example

<?php
  $dbconn = pg_connect("dbname=publisher") or die("Could not connect");
  $stat = pg_transaction_status($dbconn);
  if ($stat === PGSQL_TRANSACTION_UNKNOWN) {
      echo 'Connection is bad';
  } else if ($stat === PGSQL_TRANSACTION_IDLE) {
      echo 'Connection is currently idle';
  } else {
      echo 'Connection is in a transaction state';
  }    
?>