array ( 0 => 'index.php', 1 => 'PHP Manual', ), 'head' => array ( 0 => 'UTF-8', 1 => 'es', ), 'this' => array ( 0 => 'function.pg-transaction-status.php', 1 => 'pg_transaction_status', ), 'up' => array ( 0 => 'ref.pgsql.php', 1 => 'Funciones de 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' => 'es', 'path' => 'reference/pgsql/functions/pg-transaction-status.xml', ), ); $setup["toc"] = $TOC; $setup["toc_deprecated"] = $TOC_DEPRECATED; $setup["parents"] = $PARENTS; manual_setup($setup); ?>
(PHP 5 >= 5.1.0, PHP 7, PHP 8)
pg_transaction_status — Devuelve el estado actual de la transaccion del servidor
Devuelve el estado actual de la transacción del servidor.
pg_transaction_status() Dará resultados incorrectos al usar un
servidor PostgreSQL 7.3 que tenga el parámetro autocommit
establecido en off. La función de autocommit del lado del servidor esta obsoleta
y no existe en las versiones posteriores del servidor.
connection
Recurso de conexión a la base de datos PostgreSQL.
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.
Ejemplo #1 Ejemplo de 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';
}
?>