SitePoint Sponsor

User Tag List

Results 1 to 2 of 2
  1. #1
    SitePoint Addict
    Join Date
    Nov 2006
    0 Post(s)
    0 Thread(s)

    Transaction Behavior please explain.

    So I'm trying to program a transaction using Doctrine DBAL and I wasn't able to make it work as I expected so I decided to go directly into Mysql and try my luck directly into the beast but I'm at a lost.

    Here is what I am querying directly into Mysql
    Code SQL:
    SELECT id,ip FROM member;
    UPDATE member SET ip=888 WHERE id=120;  -- non existent row
    UPDATE member SET ip=888 WHERE id=0;      -- existent row
    -- Update member set isdfsdfp=666 where id=0; -- non existent column
    SELECT id,ip FROM member;

    The problem here is that the row with id=120 does not exist. Yet when the above is run the commit is successful.
    Interestingly also if I un-comment the last update line (which updates an non-existent column) then the code just stops it will commit the first part but it won't preform the last select.

    I'm starting to wonder what the point is of transactions if they don't work?
    Please...Never describe anything to me using foo and bar.

  2. #2
    Barefoot on the Moon! silver trophy Force Flow's Avatar
    Join Date
    Jul 2003
    Northeastern USA
    56 Post(s)
    1 Thread(s)
    It looks like you may need the ROLLBACK statement

    MySQL Transaction Gotchas & Good Parts SitePoint
    Visit The Blog | Follow On Twitter
    301tool 1.1.5 - URL redirector & shortener (PHP/MySQL)
    Can be hosted on and utilize your own domain


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts