Just issue a pg_query("begin");
at the beginning of your page and a
pg_query("commit"):
at the end.
If there are any errors, the commit will error out.
Also, the latest version of PHP is 4.3.6, and while I'm not sure it fixes this issue or not, it might be worth trying it out.
Also, PHP 5 may have this in it. But I've not even touched that. It's up to RC status, so it should be usable for testing / development.