downloads | documentation | faq | getting help | mailing lists | licenses | wiki | reporting bugs | php.net sites | links | conferences | my php.net

search for in the

Our source is open

The syntax highlighted source is automatically generated by PHP from the plaintext script. If you're interested in what's behind the several functions we used, you can always take a look at the source of the following files:

Of course, if you want to see the source of this page, we have it available. You can also browse the SVN repository for this website on svn.php.net.

Source of: /manual/en/pdo.rollback.php

<?php
include_once $_SERVER['DOCUMENT_ROOT'] . '/include/shared-manual.inc';
$TOC = array();
$PARENTS = array();
include_once
dirname(__FILE__) ."/toc/class.pdo.inc";
$setup = array (
 
'home' =>
  array (
   
0 => 'index.php',
   
1 => 'PHP Manual',
  ),
 
'head' =>
  array (
   
0 => 'UTF-8',
   
1 => 'en',
  ),
 
'this' =>
  array (
   
0 => 'pdo.rollback.php',
   
1 => 'PDO::rollBack',
  ),
 
'up' =>
  array (
   
0 => 'class.pdo.php',
   
1 => 'The PDO class',
  ),
 
'prev' =>
  array (
   
0 => 'pdo.quote.php',
   
1 => 'PDO::quote',
  ),
 
'next' =>
  array (
   
0 => 'pdo.setattribute.php',
   
1 => 'PDO::setAttribute',
  ),
);
$setup["toc"] = $TOC;
$setup["parents"] = $PARENTS;
manual_setup($setup);

manual_header();
?>
<div id="pdo.rollback" class="refentry">
 <div class="refnamediv">
  <h1 class="refname">PDO::rollBack</h1>
  <p class="verinfo">(PHP 5 &gt;= 5.1.0, PECL pdo &gt;= 0.1.0)</p><p class="refpurpose"><span class="refname">PDO::rollBack</span> &mdash; <span class="dc-title">
   Rolls back a transaction
  </span></p>

 </div>

 <a name="pdo.rollback.description"></a><div class="refsect1 description">
  <h3 class="title">Description</h3>
  <div class="methodsynopsis dc-description">
   <span class="type">bool</span> <span class="methodname"><b>PDO::rollBack</b></span>
    ( <span class="methodparam">void</span>
   )</div>


  <p class="para rdfs-comment">
   Rolls back the current transaction, as initiated by
   <a href="pdo.begintransaction.php" class="function">PDO::beginTransaction()</a>.  It is an error to call this
   method if no transaction is active.
  </p>
  <p class="para">
   If the database was set to autocommit mode, this function will restore
   autocommit mode after it has rolled back the transaction.
  </p>
  <p class="para">
   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.
  </p>
 </div>


 <a name="pdo.rollback.returnvalues"></a><div class="refsect1 returnvalues">
  <h3 class="title">Return Values</h3>
  <p class="para">
   Returns <b><tt class="constant">TRUE</tt></b> on success or <b><tt class="constant">FALSE</tt></b> on failure.
  </p>
 </div>


 <a name="pdo.rollback.examples"></a><div class="refsect1 examples">
  <h3 class="title">Examples</h3>
  <p class="para">
   </p><div class="example"><p><b>Example #1 Roll back a transaction</b></p>
    <div class="example-contents para"><p>
     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.
    </p></div>
    <div class="example-contents programlisting">
<div class="phpcode"><code><span style="color: #000000">
<span style="color: #0000BB">&lt;?php<br /></span><span style="color: #FF8000">/*&nbsp;Begin&nbsp;a&nbsp;transaction,&nbsp;turning&nbsp;off&nbsp;autocommit&nbsp;*/<br /></span><span style="color: #0000BB">$dbh</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">beginTransaction</span><span style="color: #007700">();<br /><br /></span><span style="color: #FF8000">/*&nbsp;Change&nbsp;the&nbsp;database&nbsp;schema&nbsp;and&nbsp;data&nbsp;*/<br /></span><span style="color: #0000BB">$sth&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">$dbh</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">exec</span><span style="color: #007700">(</span><span style="color: #DD0000">"DROP&nbsp;TABLE&nbsp;fruit"</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">$sth&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">$dbh</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">exec</span><span style="color: #007700">(</span><span style="color: #DD0000">"UPDATE&nbsp;dessert<br />&nbsp;&nbsp;&nbsp;&nbsp;SET&nbsp;name&nbsp;=&nbsp;'hamburger'"</span><span style="color: #007700">);<br /><br /></span><span style="color: #FF8000">/*&nbsp;Recognize&nbsp;mistake&nbsp;and&nbsp;roll&nbsp;back&nbsp;changes&nbsp;*/<br /></span><span style="color: #0000BB">$dbh</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">rollBack</span><span style="color: #007700">();<br /><br /></span><span style="color: #FF8000">/*&nbsp;Database&nbsp;connection&nbsp;is&nbsp;now&nbsp;back&nbsp;in&nbsp;autocommit&nbsp;mode&nbsp;*/<br /></span><span style="color: #0000BB">?&gt;</span>
</span>
</code></div>
    </div>

   </div><p>
  </p>
 </div>


 <a name="pdo.rollback.seealso"></a><div class="refsect1 seealso">
  <h3 class="title">See Also</h3>
  <p class="para">
   </p><ul class="simplelist">
    <li class="member"><a href="pdo.begintransaction.php" class="function" rel="rdfs-seeAlso">PDO::beginTransaction()</a> - Initiates a transaction</li>
    <li class="member"><a href="pdo.commit.php" class="function" rel="rdfs-seeAlso">PDO::commit()</a> - Commits a transaction</li>
   </ul><p>
  </p>
 </div>



</div><?php manual_footer(); ?>
 
show source | credits | sitemap | contact | advertising | mirror sites