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); pg_send_query($conn, 'SELECT 1');
$status = pg_transaction_status($conn); $res = pg_get_result($conn);
$status = pg_transaction_status($conn); $res = pg_get_result($conn); $status = pg_transaction_status($conn); ?>