mirror of
https://github.com/php/doc-ja.git
synced 2026-03-24 15:12:22 +01:00
162 lines
5.2 KiB
XML
162 lines
5.2 KiB
XML
<?xml version="1.0" encoding="utf-8" ?>
|
|
<!-- $Revision$ -->
|
|
<!-- EN-Revision: 5e41012cfdf8f2eff5fa56de446c7656afac536c Maintainer: shimooka Status: ready -->
|
|
<refentry xml:id="function.oci-commit" xmlns="http://docbook.org/ns/docbook">
|
|
<refnamediv>
|
|
<refname>oci_commit</refname>
|
|
<refpurpose>未解決のトランザクションをコミットする</refpurpose>
|
|
</refnamediv>
|
|
|
|
<refsect1 role="description">
|
|
&reftitle.description;
|
|
<methodsynopsis>
|
|
<type>bool</type><methodname>oci_commit</methodname>
|
|
<methodparam><type>resource</type><parameter>connection</parameter></methodparam>
|
|
</methodsynopsis>
|
|
<para>
|
|
Oracle接続<parameter>connection</parameter>
|
|
上の未解決なトランザクションをコミットします。
|
|
コミットすると、現在のトランザクションを終了してすべての変更を確定させます。
|
|
また、保持しているロックをすべて解放します。
|
|
</para>
|
|
<para>
|
|
トランザクションが始まるのは、データを変更する最初の SQL 文が
|
|
<constant>OCI_NO_AUTO_COMMIT</constant> フラグつきで
|
|
<function>oci_execute</function> によって実行されたときです。
|
|
それ以降、他の文によるデータの変更も同じトランザクションの一部となります。
|
|
トランザクション内でのデータの変更は、
|
|
そのトランザクションがコミットあるいはロールバックされるまでは一時的なものとなります。
|
|
データベース上の他のユーザーは、
|
|
トランザクションがコミットされるまでその変更内容を見ることができません。
|
|
</para>
|
|
<para>
|
|
データを追加したり更新したりする際には、
|
|
リレーショナルデータの一貫性やパフォーマンスなどを考慮して
|
|
トランザクションを使うことを推奨します。
|
|
</para>
|
|
</refsect1>
|
|
|
|
<refsect1 role="parameters">
|
|
&reftitle.parameters;
|
|
<para>
|
|
<variablelist>
|
|
<varlistentry>
|
|
<term><parameter>connection</parameter></term>
|
|
<listitem>
|
|
<para>
|
|
<function>oci_connect</function>、<function>oci_pconnect</function>
|
|
あるいは <function>oci_new_connect</function> が返す
|
|
Oracle 接続 ID。
|
|
</para>
|
|
</listitem>
|
|
</varlistentry>
|
|
</variablelist>
|
|
</para>
|
|
</refsect1>
|
|
|
|
<refsect1 role="returnvalues">
|
|
&reftitle.returnvalues;
|
|
<para>
|
|
&return.success;
|
|
</para>
|
|
</refsect1>
|
|
|
|
<refsect1 role="examples">
|
|
&reftitle.examples;
|
|
<para>
|
|
<example>
|
|
<title><function>oci_commit</function> の例</title>
|
|
<programlisting role="php">
|
|
<![CDATA[
|
|
<?php
|
|
|
|
// 複数のテーブルに挿入し、エラーが発生したときにはロールバックします
|
|
|
|
$conn = oci_connect('hr', 'welcome', 'localhost/XE');
|
|
|
|
$stid = oci_parse($conn, "INSERT INTO mysalary (id, name) VALUES (1, 'Chris')");
|
|
|
|
// OCI_NO_AUTO_COMMIT フラグは、INSERT の直後にコミットしないよう Oracle に指示します
|
|
$r = oci_execute($stid, OCI_NO_AUTO_COMMIT);
|
|
if (!$r) {
|
|
$e = oci_error($stid);
|
|
trigger_error(htmlentities($e['message']), E_USER_ERROR);
|
|
}
|
|
|
|
$stid = oci_parse($conn, 'INSERT INTO myschedule (startday) VALUES (12)');
|
|
$r = oci_execute($stid, OCI_NO_AUTO_COMMIT);
|
|
if (!$r) {
|
|
$e = oci_error($stid);
|
|
oci_rollback($conn); // 両方のテーブルへの変更をロールバックします
|
|
trigger_error(htmlentities($e['message']), E_USER_ERROR);
|
|
}
|
|
|
|
// 両方のテーブルへの変更をコミットします
|
|
$r = oci_commit($conn);
|
|
if (!$r) {
|
|
$e = oci_error($conn);
|
|
trigger_error(htmlentities($e['message']), E_USER_ERROR);
|
|
}
|
|
|
|
?>
|
|
]]>
|
|
</programlisting>
|
|
</example>
|
|
</para>
|
|
</refsect1>
|
|
|
|
<refsect1 role="notes">
|
|
&reftitle.notes;
|
|
<note>
|
|
<para>
|
|
トランザクションは接続を閉じたとき、
|
|
もしくはスクリプトの終了時のいずれの場合でも
|
|
すぐに自動的にロールバックされます。
|
|
トランザクションをコミットするには
|
|
<function>oci_commit</function> をコールする必要があります。
|
|
</para>
|
|
<para>
|
|
<constant>OCI_COMMIT_ON_SUCCESS</constant> モードを指定するか、
|
|
あるいはデフォルトの状態で <function>oci_execute</function> をコールすると、
|
|
それ以前の未コミットのトランザクションをコミットします。
|
|
</para>
|
|
<para>
|
|
<literal>CREATE</literal> や <literal>DROP</literal> といった
|
|
Oracle の DDL は、未コミットのトランザクションを自動的にコミットします。
|
|
</para>
|
|
</note>
|
|
</refsect1>
|
|
|
|
<refsect1 role="seealso">
|
|
&reftitle.seealso;
|
|
<para>
|
|
<simplelist>
|
|
<member><function>oci_execute</function></member>
|
|
<member><function>oci_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
|
|
-->
|