From: | "David Legault" <legault(dot)david(at)gmail(dot)com> |
---|---|
To: | mikie <mikie(dot)pl(at)gmail(dot)com> |
Cc: | pgsql-php(at)postgresql(dot)org |
Subject: | Re: transactions from PHP - double COMMIT required? |
Date: | 2007-03-01 12:18:54 |
Message-ID: | e0b20d410703010418m3f931527wb2e81e3f3ab0c9f4@mail.gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | Postg토토 커뮤니티SQL : Postg토토 커뮤니티SQL 메일 링리스트 : 2007-03-01 이후 PGSQL-PHP 12:18 |
If you are using PHP5 (and the PDO PGSQL) I would suggest you use exceptions
to trap the error
try {
$db->beginTransaction();
// other queries here, if one fails, an exception is thrown
$db->commit();
}
catch (Exception $e) {
// do whatever with error
$db->rollback();
}
On 3/1/07, mikie <mikie(dot)pl(at)gmail(dot)com> wrote:
>
>
>
> 2007/3/1, Mihail Mihailov <Mihail(dot)Mihailov(at)uta(dot)fi>:
> >
> > Hi,
> >
> > I think you should use ROLLBACK if the query cannot be executed.
> > one can commit only results of the queries that work.
> > Try ROLLBACK statement.
> >
> > The thing is that when I try my transaction from psql console then the
> command ROLLBACK is being issued by the postgres server itself right after I
> close my transaction with COMMIT;. According to transaction logic and idea -
> if something goes wrong then the entire transaction is being cancelled by
> ROLLBACK - it is the server responsibility to rollback such transaction.
>
> Now, when I try to do some inserts within my transaction I don't know if
> they will fail or not. Eitherway I am closing my transaction with the
> COMMIT; command - is that correct way ?
> It works logically OK from within psql console (I start with BEGIN and
> then close my sql commands with commit) but it does not work this way from
> within PHP script. I believe there is some issue with PHP - I am not sure if
> PHP processor applies some changes to my query and thus ignores the commit
> command?
>
> --
> Mike
>
>
From | Date | Subject | |
---|---|---|---|
Next Message | mikie | 2007-03-01 12:45:08 | Re: transactions from PHP - double COMMIT required? |
Previous Message | mikie | 2007-03-01 11:29:58 | Re: transactions from PHP - double COMMIT required? |