Fix doc bug #62503 (DDL statements in PDO queries are implicitly commited!).

git-svn-id: https://svn.php.net/repository/phpdoc/en/trunk@326723 c90b9560-bf6c-de11-be94-00142212c4b1
This commit is contained in:
Adam Harvey 2012-07-20 06:21:14 +00:00
parent 2726a42e43
commit ef51bbad95

View file

@ -31,7 +31,41 @@
<refsect1 role="examples">
&reftitle.examples;
<para>
<example><title>Commit a transaction</title>
<example>
<title>Committing a basic transaction</title>
<programlisting role="php">
<![CDATA[
<?php
/* Begin a transaction, turning off autocommit */
$dbh->beginTransaction();
/* Insert multiple records on an all-or-nothing basis */
$sql = 'INSERT INTO fruit
(name, colour, calories)
VALUES (?, ?, ?)';
$sth = $dbh->prepare($sql);
foreach ($fruits as $fruit) {
$sth->execute(array(
$fruit->name,
$fruit->colour,
$fruit->calories,
));
}
/* Commit the changes */
$dbh->commit();
/* Database connection is now back in autocommit mode */
?>
]]>
</programlisting>
</example>
</para>
<para>
<example>
<title>Committing a DDL transaction</title>
<programlisting role="php">
<![CDATA[
<?php
@ -49,6 +83,14 @@ $dbh->commit();
]]>
</programlisting>
</example>
<note>
<simpara>
Not all databases will allow transactions to operate on DDL statements:
some will generate errors, whereas others (including MySQL) will
automatically commit the transaction after the first DDL statement has
been encountered.
</simpara>
</note>
</para>
</refsect1>