mirror of
https://github.com/sigmasternchen/php-doc-en
synced 2025-03-26 22:08:55 +00:00

Based on a patch provided by Kasper Franz. git-svn-id: https://svn.php.net/repository/phpdoc/en/trunk@346087 c90b9560-bf6c-de11-be94-00142212c4b1
166 lines
4.6 KiB
XML
166 lines
4.6 KiB
XML
<?xml version="1.0" encoding="utf-8"?>
|
|
<!-- $Revision$ -->
|
|
|
|
<refentry xml:id="mysqli.begin-transaction" xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink">
|
|
<refnamediv>
|
|
<refname>mysqli::begin_transaction</refname>
|
|
<refname>mysqli_begin_transaction</refname>
|
|
<refpurpose>Starts a transaction</refpurpose>
|
|
</refnamediv>
|
|
|
|
<refsect1 role="description">
|
|
&reftitle.description;
|
|
<para>&style.oop; (method):</para>
|
|
<methodsynopsis>
|
|
<modifier>public</modifier> <type>bool</type><methodname>mysqli::begin_transaction</methodname>
|
|
<methodparam choice="opt"><type>int</type><parameter>flags</parameter><initializer>0</initializer></methodparam>
|
|
<methodparam choice="opt"><type>string</type><parameter>name</parameter></methodparam>
|
|
</methodsynopsis>
|
|
<para>&style.procedural;:</para>
|
|
<methodsynopsis>
|
|
<type>bool</type><methodname>mysqli_begin_transaction</methodname>
|
|
<methodparam><type>mysqli</type><parameter>link</parameter></methodparam>
|
|
<methodparam choice="opt"><type>int</type><parameter>flags</parameter><initializer>0</initializer></methodparam>
|
|
<methodparam choice="opt"><type>string</type><parameter>name</parameter></methodparam>
|
|
</methodsynopsis>
|
|
<para>
|
|
Begins a transaction. Requires the InnoDB
|
|
engine (it is enabled by default). For additional details about how MySQL transactions
|
|
work, see <link xlink:href="&url.mysql.docs.commit;">&url.mysql.docs.commit;</link>.
|
|
</para>
|
|
</refsect1>
|
|
|
|
<refsect1 role="parameters">
|
|
&reftitle.parameters;
|
|
<para>
|
|
<variablelist>
|
|
&mysqli.link.description;
|
|
<varlistentry>
|
|
<term><parameter>flags</parameter></term>
|
|
<listitem>
|
|
<para>
|
|
Valid flags are:
|
|
</para>
|
|
<itemizedlist>
|
|
<listitem>
|
|
<para>
|
|
<constant>MYSQLI_TRANS_START_READ_ONLY</constant>:
|
|
Start the transaction as "START TRANSACTION READ ONLY".
|
|
Requires MySQL 5.6 and above.
|
|
</para>
|
|
</listitem>
|
|
<listitem>
|
|
<para>
|
|
<constant>MYSQLI_TRANS_START_READ_WRITE</constant>:
|
|
Start the transaction as "START TRANSACTION READ WRITE".
|
|
Requires MySQL 5.6 and above.
|
|
</para>
|
|
</listitem>
|
|
<listitem>
|
|
<para>
|
|
<constant>MYSQLI_TRANS_START_WITH_CONSISTENT_SNAPSHOT</constant>:
|
|
Start the transaction as "START TRANSACTION WITH CONSISTENT SNAPSHOT".
|
|
</para>
|
|
</listitem>
|
|
</itemizedlist>
|
|
</listitem>
|
|
</varlistentry>
|
|
<varlistentry>
|
|
<term><parameter>name</parameter></term>
|
|
<listitem>
|
|
<para>
|
|
Savepoint name for the transaction.
|
|
</para>
|
|
</listitem>
|
|
</varlistentry>
|
|
</variablelist>
|
|
</para>
|
|
</refsect1>
|
|
|
|
<refsect1 role="returnvalues">
|
|
&reftitle.returnvalues;
|
|
<para>
|
|
&return.success;
|
|
</para>
|
|
</refsect1>
|
|
|
|
<refsect1 role="examples">
|
|
&reftitle.examples;
|
|
<example>
|
|
<title><methodname>$mysqli->begin_transaction</methodname> example</title>
|
|
<para>&style.oop;</para>
|
|
<programlisting role="php">
|
|
<![CDATA[
|
|
<?php
|
|
$mysqli = new mysqli("127.0.0.1", "my_user", "my_password", "sakila");
|
|
|
|
if ($mysqli->connect_errno) {
|
|
printf("Connect failed: %s\n", $mysqli->connect_error);
|
|
exit();
|
|
}
|
|
|
|
$mysqli->begin_transaction(MYSQLI_TRANS_START_READ_ONLY);
|
|
|
|
$mysqli->query("SELECT first_name, last_name FROM actor");
|
|
$mysqli->commit();
|
|
|
|
$mysqli->close();
|
|
?>
|
|
]]>
|
|
</programlisting>
|
|
<para>&style.procedural;</para>
|
|
<programlisting role="php">
|
|
<![CDATA[
|
|
<?php
|
|
$link = mysqli_connect("127.0.0.1", "my_user", "my_password", "sakila");
|
|
|
|
if (mysqli_connect_errno()) {
|
|
printf("Connect failed: %s\n", mysqli_connect_error());
|
|
exit();
|
|
}
|
|
|
|
mysqli_begin_transaction($link, MYSQLI_TRANS_START_READ_ONLY);
|
|
|
|
mysqli_query($link, "SELECT first_name, last_name FROM actor LIMIT 1");
|
|
mysqli_commit($link);
|
|
|
|
mysqli_close($link);
|
|
?>
|
|
]]>
|
|
</programlisting>
|
|
</example>
|
|
</refsect1>
|
|
|
|
<refsect1 role="seealso">
|
|
&reftitle.seealso;
|
|
<para>
|
|
<simplelist>
|
|
<member><function>mysqli_autocommit</function></member>
|
|
<member><function>mysqli_commit</function></member>
|
|
<member><function>mysqli_rollback</function></member>
|
|
</simplelist>
|
|
</para>
|
|
</refsect1>
|
|
|
|
</refentry>
|
|
|
|
<!-- Keep this comment at the end of the file
|
|
Local variables:
|
|
mode: sgml
|
|
sgml-omittag:t
|
|
sgml-shorttag:t
|
|
sgml-minimize-attributes:nil
|
|
sgml-always-quote-attributes:t
|
|
sgml-indent-step:1
|
|
sgml-indent-data:t
|
|
indent-tabs-mode:nil
|
|
sgml-parent-document:nil
|
|
sgml-default-dtd-file:"~/.phpdoc/manual.ced"
|
|
sgml-exposed-tags:nil
|
|
sgml-local-catalogs:nil
|
|
sgml-local-ecat-files:nil
|
|
End:
|
|
vim600: syn=xml fen fdm=syntax fdl=2 si
|
|
vim: et tw=78 syn=sgml
|
|
vi: ts=1 sw=1
|
|
-->
|