php & postgresql - all or nothing

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Alexander Ross

    php & postgresql - all or nothing

    Lets say I want to execute 3 postgresql queries in a row based on the
    inputs in a php form...Here's the catch though. What happens if #1 and #2
    execute perfectly, but #3 fails for one reason or another. Is there a way to
    set things up so that the server knows and compensates... in other words...

    do queries 1,2&3, but if any query is unsuccessfull set the db back to the
    way it was before any of the queries executed.

    Please speak slowly ... I'm still getting the hang of postgresql

    --
    Alexander Ross
    alexross@bleen. net


  • Jim Dabell

    #2
    Re: php & postgresql - all or nothing

    Alexander Ross wrote:

    [snip][color=blue]
    > do queries 1,2&3, but if any query is unsuccessfull set the db back to the
    > way it was before any of the queries executed.[/color]
    [snip]

    You are talking about transactions. The basic model is:

    BEGIN;
    ....
    COMMIT;

    <URL:http://www.phpfreaks.c om/postgresqlmanua l/page/tutorial-transactions.ht ml>


    --
    Jim Dabell

    Comment

    Working...