Related Links : Search Engine Optimization | | Search Engine Marketing | Online Marketing | Freelance Programmer| SEO Thailand | SEO Expert | SEO services | PHP Programmer Thailand | SEO Tutorial | What is SEO |

  Home Our SEO Services SEO Expert Consultant Php Programmer Keyword Suggestion Scripts|Articles| Email : sachin {at} jainsachin {dot} com

PHP | Rolls back a transaction | Manual | Tutorial | Help

SEO Services



Website Programming in PHP / MYSQL



SEO Tools




    Friends


      Rolls back a transaction

      PDO::rollBack

      (PHP 5 >= 5.1.0, PECL pdo:0.1-1.0.3)

      PDO::rollBack — Rolls back a transaction

      Description

      bool PDO::rollBack ( void )

      Rolls back the current transaction, as initiated by PDO::beginTransaction(). It is an error to call this method if no transaction is active.

      If the database was set to autocommit mode, this function will restore autocommit mode after it has rolled back the transaction.

      Some databases, including MySQL, automatically issue an implicit COMMIT when a database definition language (DDL) statement such as DROP TABLE or CREATE TABLE is issued within a transaction. The implicit COMMIT will prevent you from rolling back any other changes within the transaction boundary.

      Return Values

      Returns TRUE on success or FALSE on failure.

      Examples

      Example #1 Roll back a transaction

      The following example begins a transaction and issues two statements that modify the database before rolling back the changes. On MySQL, however, the DROP TABLE statement automatically commits the transaction so that none of the changes in the transaction are rolled back.

      <?php
      /* Begin a transaction, turning off autocommit */
      $dbh->beginTransaction();

      /* Change the database schema and data */
      $sth $dbh->exec("DROP TABLE fruit");
      $sth $dbh->exec("UPDATE dessert
          SET name = 'hamburger'"
      );

      /* Recognize mistake and roll back changes */
      $dbh->rollBack();

      /* Database connection is now back in autocommit mode */
      ?>


      SEO Tutorial / Articles





      Php / Mysql Tutorial



      Articles



        Other Topics



        SEO by Jainsachin