PHP: pg_transaction_status - Manual

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

search for in the

pg_tty pg_trace

Last updated: Sat, 27 Jan 2007

view this page in

# pg_transaction_status

(PHP 5 >= 5.1.0RC1)

pg_transaction_status -- Returns the current in-transaction status of the server.

## Описание

int pg_transaction_status ( resource connection )

Returns the current in-transaction status of the server.

Предостережение
pg_transaction_status() will give incorrect results when using a PostgreSQL 7.3 server that has the parameter `autocommit` set to off. The server-side autocommit feature has been deprecated and does not exist in later server versions.

## Список параметров

`connection`

  PostgreSQL database connection resource.

## Возвращаемые значения

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

## Примеры

Пример 1. pg_transaction_status() 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';
}
?>`

add a note User Contributed Notes
pg_transaction_status
btherl at yahoo dot com dot au
17-Jul-2006 07: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.`
add a note
pg_tty pg_trace

Last updated: Sat, 27 Jan 2007
show source | credits | stats | sitemap | contact | advertising | mirror sites
Copyright © 2001-2007 The PHP Group
All rights reserved.
This mirror generously provided by: Yahoo! Inc.
Last updated: Sat Mar 10 10:36:09 2007 PST