PHP
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: Fri, 03 Oct 2008

view this page in

pg_transaction_status

(PHP 5 >= 5.1.0)

pg_transaction_statusサーバ上で実行中のトランザクションの状態を返す

説明

int pg_transaction_status ( resource $connection )

サーバ上で実行中のトランザクションの状態を返します。

警告

PostgreSQL 7.3 サーバで autocommit を off に 設定している場合、pg_transaction_status() は 不正確な値を返します。サーバ側での自動コミット機能は非推奨と されており、最近のバージョンのサーバでは存在しません。

パラメータ

connection

PostgreSQL データベースの接続リソース。

返り値

PGSQL_TRANSACTION_IDLE(アイドル状態)、 PGSQL_TRANSACTION_ACTIVE(コマンドの実行中)、 PGSQL_TRANSACTION_INTRANS(正常なトランザクション内でアイドル状態)、 あるいは PGSQL_TRANSACTION_INERROR(失敗したトランザクション内でアイドル状態) のいずれかを返します。 接続が異常な場合は PGSQL_TRANSACTION_UNKNOWN を返します。 PGSQL_TRANSACTION_ACTIVE が返されるのは、クエリを サーバに送信した後まだそれが完了していない場合のみです。

例1 pg_transaction_status() の例

<?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 add a note User Contributed Notes
pg_transaction_status
btherl at yahoo dot com dot au
18-Jul-2006 11: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.

pg_tty> <pg_trace
Last updated: Fri, 03 Oct 2008
 
 
show source | credits | sitemap | contact | advertising | mirror sites