Re: *** QUESTION *** After successful 'BEGIN;' command -- why PGSQL_TRANSACTION_ACTIVE and not PGSQL_TRANSACTION_INTRANS?
В списке pgsql-general по дате отправления:
| От | Daniel Verite |
|---|---|
| Тема | Re: *** QUESTION *** After successful 'BEGIN;' command -- why PGSQL_TRANSACTION_ACTIVE and not PGSQL_TRANSACTION_INTRANS? |
| Дата | |
| Msg-id | 507ade55-c5c8-468f-8f0e-745a8a7b9878@mm обсуждение исходный текст |
| Ответ на | Re: *** QUESTION *** After successful 'BEGIN;' command -- why PGSQL_TRANSACTION_ACTIVE and not PGSQL_TRANSACTION_INTRANS? ("Steve Petrie, P.Eng." <apetrie@aspetrie.net>) |
| Список | pgsql-general |
Steve Petrie, P.Eng. wrote:
> And yes, I am using pg_send_query(...) to execute the BEGIN; command, so as
> to get a result resource returned. (Please see my forthcoming emailed
> response to Adrian Klaver, wherein I provide the PHP source code that Adrian
> requests.)
After successfully calling pg_send_query($cnx, $query),
pg_transaction_status($cnx) will return PGSQL_TRANSACTION_ACTIVE
until the results have been collected by looping over pg_get_result($cnx).
This is for any query, not specifically $query="BEGIN".
Example:
<?php
if (pg_send_query($dbcnx, "BEGIN")) {
do {
$res=pg_get_result($dbcnx);
// error processing here
} while ($res);
echo pg_transaction_status($dbcnx);
?>
This will output 2, which corresponds to PGSQL_TRANSACTION_INTRANS
as expected.
OTOH if commenting the call to pg_get_result($dbcnx), then
it ouputs 1 (PGSQL_TRANSACTION_ACTIVE) as you mentioned.
Best regards,
--
Daniel Vérité
PostgreSQL-powered mailer: http://www.manitou-mail.org
Twitter: @DanielVerite
В списке pgsql-general по дате отправления:
Сайт использует файлы cookie для корректной работы и повышения удобства. Нажимая кнопку «Принять» или продолжая пользоваться сайтом, вы соглашаетесь на их использование в соответствии с Политикой в отношении обработки cookie ООО «ППГ», в том числе на передачу данных из файлов cookie сторонним статистическим и рекламным службам. Вы можете управлять настройками cookie через параметры вашего браузера