Transactions avoid situations such as records of data are recorded on a provisional and not final until you take a statement confirming that these entries are final. To this end, MySQL has three statements: BEGIN, COMMIT and ROLLBACK.
There are three statements to manage transactions. They are:
mysql_query ("BEGIN", $ c)
Its implementation requires that $ c enable connection to the server database and instructs MySQL starting a transaction. All sentences to run from it are provisional and are not effectively implemented until a sentence completion.
mysql_query ("ROLLBACK", $ c)
By this statement warned MySQL transaction is complete but should not be paid any changes included in it.
mysql_query ("COMMIT", $ c)
This statement warns MySQL has completed the transaction and should implement all the changes included in it. When using AUTO_INCREMENT fields in InnoDB tables counters are increasing when adding records (even temporarily) so if the inclusion is aborted with a ROLLBACK that counter keeps increasing and insertions that leave equity. For example. If we start with an empty table and make a transaction in two registers (No. 1 and No. 2 in auto-increment) and end with ROLLBACK, but not inserted in a later insertion auto-increment the counter value starting from 2. MySQL announces that as of version 5.0.3 will include a new sentence to allow AUTO_INCREMENT fields to renumber.
Bookmarks