[prev in list] [next in list] [prev in thread] [next in thread] 

List:       php-general
Subject:    [PHP] Explanation of asynchronous postgres interface
From:       "Gary ." <php-general () garydjones ! name>
Date:       2010-04-28 10:52:01
Message-ID: r2ka35643581004280352n45243d3fof9d3d115fea139bc () mail ! gmail ! com
[Download RAW message or body]

I asked something similar to this on the ph-db ml yesterday, but that
list seems to be almost dead.

The situation I have is that I am trying to get the postgres error
code (as opposed to some error message - see my other posts to this
list over the last day or so for the background to that). I found I
could use pg_result_error_field to do this, but that requires me using
pg_get_result (and, basically, the rest of the async part of the
interface). That's okay. As long as I can get the error code I'm happy
enough with that in principle.

The problem is that I have my asynchronous inserts wrapped in a transaction:
BEGIN
for (...)
{
  pg_send_execute(...);
}
COMMIT

So, where should my pg_get_result and other error checking go? I've
put it immediately after the while loop, and it works okay in a
phpunit-test that forces a UNIQUEness constraint to fire - the code
picks up the expected 23505 error code, and I can get that in the
client code and translate it to a nice user message. However, running
through the normal interface, provoking the same error, I instead get
25P02 ("in_failed_sql_transaction"). Why, and how can I make sure I
get the original error?

TIA.

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic