Using transactions with PHP and MySQL?

Discussion in 'PHP' started by jijihuqw, Jul 13, 2011.

  1. #1
    Hi!
    Has anyone managed to use transactions with MySQL and Php?
    The server I'm currently on does have problems with database connections from time to time. (It has happened that new players have signed up, but not received any activation e-mail because the database connection was lost in between actions).

    I've tried to use SET AUTOCOMMIT=0 and then use BEGIN, END and COMMIT statements.
    If I put an "exit;" (in the php code) and halts it before the COMMIT, all changes should be rolled-back right? It seems like it doesn't.
    Or is the mysqli class a better alternative?
     
    jijihuqw, Jul 13, 2011 IP
  2. lukeg32

    lukeg32 Peon

    Messages:
    645
    Likes Received:
    19
    Best Answers:
    1
    Trophy Points:
    0
    #2
    What storage engine are you using? By its very nature, MyISAM will always be autocommit=1 because of its atomic operations.

    postgres might be the better choice ;-)
     
    lukeg32, Jul 14, 2011 IP