note 126528 added to function.pg-transaction-status
| From: | r dot grellmann at agentmulder dot de | Date: | Sat, 23 Oct 2021 02:17:28 +0000 |
| Subject: | note 126528 added to function.pg-transaction-status | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-217101@lists.php.net to get a copy of this message | ||
After one of the asynchronous functions (pg_send_query(), pg_send_query_params()...) has been used,
pg_transaction_status() will always report PGSQL_TRANSACTION_ACTIVE, no matter if a transaction was
started or not.
Even after the first call (or all valid calls) to pg_get_result() the transaction status will stay
PGSQL_TRANSACTION_ACTIVE, until either
- a synchronous function like pq_query() was used, or
- another call to pg_get_result() was made, which returns false.
Note: calling pg_free_result() does not change anything.
<?php
$conn = pg_connect("dbname=publisher") or die("Could not connect");
$status = pg_transaction_status($conn); // PGSQL_TRANSACTION_IDLE
pg_send_query($conn, 'SELECT 1');
$status = pg_transaction_status($conn); // PGSQL_TRANSACTION_ACTIVE
$res = pg_get_result($conn);
$status = pg_transaction_status($conn); // PGSQL_TRANSACTION_ACTIVE
$res = pg_get_result($conn); // false
$status = pg_transaction_status($conn); // PGSQL_TRANSACTION_IDLE
?>
----
Server IP: 45.112.84.4
Probable Submitter: 45.112.85.242 (proxied: 194.140.231.93)
----
Manual Page -- https://php.net/manual/en/function.pg-transaction-status.php
Edit -- https://main.php.net/note/edit/126528
Del: integrated -- https://main.php.net/note/delete/126528/integrated
Del: useless -- https://main.php.net/note/delete/126528/useless
Del: bad code -- https://main.php.net/note/delete/126528/bad+code
Del: spam -- https://main.php.net/note/delete/126528/spam
Del: non-english -- https://main.php.net/note/delete/126528/non-english
Del: in docs -- https://main.php.net/note/delete/126528/in+docs
Del: other reasons-- https://main.php.net/note/delete/126528
Reject -- https://main.php.net/note/reject/126528
Search -- https://main.php.net/manage/user-notes.php