<?php
include_once $_SERVER['DOCUMENT_ROOT'] . '/include/shared-manual.inc';
$TOC = array();
$TOC_DEPRECATED = array();
$PARENTS = array();
include_once dirname(__FILE__) ."/toc/ref.pgsql.inc";
$setup = array (
  'home' => 
  array (
    0 => 'index.php',
    1 => 'PHP Manual',
  ),
  'head' => 
  array (
    0 => 'UTF-8',
    1 => 'ja',
  ),
  'this' => 
  array (
    0 => 'function.pg-transaction-status.php',
    1 => 'pg_transaction_status',
    2 => 'サーバー上で実行中のトランザクションの状態を返す',
  ),
  'up' => 
  array (
    0 => 'ref.pgsql.php',
    1 => 'PostgreSQL 関数',
  ),
  'prev' => 
  array (
    0 => 'function.pg-trace.php',
    1 => 'pg_trace',
  ),
  'next' => 
  array (
    0 => 'function.pg-tty.php',
    1 => 'pg_tty',
  ),
  'alternatives' => 
  array (
  ),
  'source' => 
  array (
    'lang' => 'ja',
    'path' => 'reference/pgsql/functions/pg-transaction-status.xml',
  ),
  'history' => 
  array (
  ),
);
$setup["toc"] = $TOC;
$setup["toc_deprecated"] = $TOC_DEPRECATED;
$setup["parents"] = $PARENTS;
manual_setup($setup);

contributors($setup);

?>
<div id="function.pg-transaction-status" class="refentry">
 <div class="refnamediv">
  <h1 class="refname">pg_transaction_status</h1>
  <p class="verinfo">(PHP 5 &gt;= 5.1.0, PHP 7, PHP 8)</p><p class="refpurpose"><span class="refname">pg_transaction_status</span> &mdash; <span class="dc-title">サーバー上で実行中のトランザクションの状態を返す</span></p>

 </div>

 <div class="refsect1 description" id="refsect1-function.pg-transaction-status-description">
  <h3 class="title">説明</h3>
  <div class="methodsynopsis dc-description">
   <span class="methodname"><strong>pg_transaction_status</strong></span>(<span class="methodparam"><span class="type"><a href="class.pgsql-connection.php" class="type PgSql\Connection">PgSql\Connection</a></span> <code class="parameter">$connection</code></span>): <span class="type"><a href="language.types.integer.php" class="type int">int</a></span></div>

  <p class="para rdfs-comment">
    サーバー上で実行中のトランザクションの状態を返します。
  </p>
  <div class="caution"><strong class="caution">警告</strong>
    <p class="para">
      PostgreSQL 7.3 サーバーで <code class="literal">autocommit</code> を off に
      設定している場合、<span class="function"><strong>pg_transaction_status()</strong></span> は
      不正確な値を返します。サーバー側での自動コミット機能は非推奨と
      されており、最近のバージョンのサーバーでは存在しません。
    </p>
  </div>
 </div>


 <div class="refsect1 parameters" id="refsect1-function.pg-transaction-status-parameters">
  <h3 class="title">パラメータ</h3>
  <p class="para">
   <dl>
    
     <dt><code class="parameter">connection</code></dt>
     <dd>
      <p class="para"><span class="classname"><a href="class.pgsql-connection.php" class="classname">PgSql\Connection</a></span> クラスのインスタンス。</p>
     </dd>
    
   </dl>
  </p>
 </div>


 <div class="refsect1 returnvalues" id="refsect1-function.pg-transaction-status-returnvalues">
  <h3 class="title">戻り値</h3>
  <p class="para"><strong><code><a href="pgsql.constants.php#constant.pgsql-transaction-idle">PGSQL_TRANSACTION_IDLE</a></code></strong>（アイドル状態）、
    <strong><code><a href="pgsql.constants.php#constant.pgsql-transaction-active">PGSQL_TRANSACTION_ACTIVE</a></code></strong>（コマンドの実行中）、
    <strong><code><a href="pgsql.constants.php#constant.pgsql-transaction-intrans">PGSQL_TRANSACTION_INTRANS</a></code></strong>（正常なトランザクション内でアイドル状態）、
    あるいは <strong><code><a href="pgsql.constants.php#constant.pgsql-transaction-inerror">PGSQL_TRANSACTION_INERROR</a></code></strong>（失敗したトランザクション内でアイドル状態）
    のいずれかを返します。
    接続が異常な場合は <strong><code><a href="pgsql.constants.php#constant.pgsql-transaction-unknown">PGSQL_TRANSACTION_UNKNOWN</a></code></strong> を返します。
    <strong><code><a href="pgsql.constants.php#constant.pgsql-transaction-active">PGSQL_TRANSACTION_ACTIVE</a></code></strong> が返されるのは、クエリを
    サーバーに送信した後まだそれが完了していない場合のみです。
  </p>
 </div>


 <div class="refsect1 changelog" id="refsect1-function.pg-transaction-status-changelog">
  <h3 class="title">変更履歴</h3>
  <table class="doctable informaltable">
   
    <thead>
     <tr>
      <th>バージョン</th>
      <th>説明</th>
     </tr>

    </thead>

    <tbody class="tbody">
     <tr>
 <td>8.1.0</td>
 <td>
  <code class="parameter">connection</code> は、<span class="classname"><a href="class.pgsql-connection.php" class="classname">PgSql\Connection</a></span> クラスのインスタンスを期待するようになりました。
  これより前のバージョンでは、<span class="type"><a href="language.types.resource.php" class="type resource">resource</a></span> を期待していました。
 </td>
</tr>

    </tbody>
   
  </table>

 </div>

 
 <div class="refsect1 examples" id="refsect1-function.pg-transaction-status-examples">
  <h3 class="title">例</h3>
  <p class="para">
   <div class="example" id="example-1">
    <p><strong>例1 <span class="function"><strong>pg_transaction_status()</strong></span> の例</strong></p>
    <div class="example-contents">
<div class="phpcode"><code><span style="color: #000000"><span style="color: #0000BB">&lt;?php<br />  $dbconn </span><span style="color: #007700">= </span><span style="color: #0000BB">pg_connect</span><span style="color: #007700">(</span><span style="color: #DD0000">"dbname=publisher"</span><span style="color: #007700">) or die(</span><span style="color: #DD0000">"Could not connect"</span><span style="color: #007700">);<br />  </span><span style="color: #0000BB">$stat </span><span style="color: #007700">= </span><span style="color: #0000BB">pg_transaction_status</span><span style="color: #007700">(</span><span style="color: #0000BB">$dbconn</span><span style="color: #007700">);<br />  if (</span><span style="color: #0000BB">$stat </span><span style="color: #007700">=== </span><span style="color: #0000BB">PGSQL_TRANSACTION_UNKNOWN</span><span style="color: #007700">) {<br />      echo </span><span style="color: #DD0000">'Connection is bad'</span><span style="color: #007700">;<br />  } else if (</span><span style="color: #0000BB">$stat </span><span style="color: #007700">=== </span><span style="color: #0000BB">PGSQL_TRANSACTION_IDLE</span><span style="color: #007700">) {<br />      echo </span><span style="color: #DD0000">'Connection is currently idle'</span><span style="color: #007700">;<br />  } else {<br />      echo </span><span style="color: #DD0000">'Connection is in a transaction state'</span><span style="color: #007700">;<br />  }    <br /></span><span style="color: #0000BB">?&gt;</span></span></code></div>
    </div>

   </div>
  </p>
 </div>


</div><?php manual_footer($setup); ?>