<?php
include_once $_SERVER['DOCUMENT_ROOT'] . '/include/shared-manual.inc';
$TOC = array();
$TOC_DEPRECATED = array();
$PARENTS = array();
include_once dirname(__FILE__) ."/toc/ref.oci8.inc";
$setup = array (
  'home' => 
  array (
    0 => 'index.php',
    1 => 'PHP Manual',
  ),
  'head' => 
  array (
    0 => 'UTF-8',
    1 => 'uk',
  ),
  'this' => 
  array (
    0 => 'function.oci-commit.php',
    1 => 'oci_commit',
    2 => 'Commits the outstanding database transaction',
  ),
  'up' => 
  array (
    0 => 'ref.oci8.php',
    1 => 'Функції OCI8',
  ),
  'prev' => 
  array (
    0 => 'function.oci-close.php',
    1 => 'oci_close',
  ),
  'next' => 
  array (
    0 => 'function.oci-connect.php',
    1 => 'oci_connect',
  ),
  'alternatives' => 
  array (
  ),
  'source' => 
  array (
    'lang' => 'en',
    'path' => 'reference/oci8/functions/oci-commit.xml',
  ),
  'history' => 
  array (
  ),
);
$setup["toc"] = $TOC;
$setup["toc_deprecated"] = $TOC_DEPRECATED;
$setup["parents"] = $PARENTS;
manual_setup($setup);

contributors($setup);

?>
<div id="function.oci-commit" class="refentry">
 <div class="refnamediv">
  <h1 class="refname">oci_commit</h1>
  <p class="verinfo">(PHP 5, PHP 7, PHP 8, PECL OCI8 &gt;= 1.1.0)</p><p class="refpurpose"><span class="refname">oci_commit</span> &mdash; <span class="dc-title">Commits the outstanding database transaction</span></p>

 </div>
 
 <div class="refsect1 description" id="refsect1-function.oci-commit-description">
  <h3 class="title">Опис</h3>
  <div class="methodsynopsis dc-description">
   <span class="methodname"><strong>oci_commit</strong></span>(<span class="methodparam"><span class="type"><a href="language.types.resource.php" class="type resource">resource</a></span> <code class="parameter">$connection</code></span>): <span class="type"><a href="language.types.boolean.php" class="type bool">bool</a></span></div>

  <p class="para rdfs-comment">
   Commits the outstanding transaction for the
   Oracle <code class="parameter">connection</code>.  A commit ends the
   current transaction and makes permanent all changes.  It releases
   all locks held.
  </p>
  <p class="para">
   A transaction begins when the first SQL statement that changes data
   is executed with <span class="function"><a href="function.oci-execute.php" class="function">oci_execute()</a></span> using
   the <strong><code><a href="oci8.constants.php#constant.oci-no-auto-commit">OCI_NO_AUTO_COMMIT</a></code></strong> flag.  Further data
   changes made by other statements become part of the same
   transaction.  Data changes made in a transaction are temporary
   until the transaction is committed or rolled back.  Other users of
   the database will not see the changes until they are committed.
  </p>
  <p class="para">
   When inserting or updating data, using transactions is recommended
   for relational data consistency and for performance reasons.
  </p>
 </div>


 <div class="refsect1 parameters" id="refsect1-function.oci-commit-parameters">
  <h3 class="title">Параметри</h3>
  <p class="para">
   <dl>
    
     <dt><code class="parameter">connection</code></dt>
     <dd>
      <p class="para">
       An Oracle connection identifier, returned by
       <span class="function"><a href="function.oci-connect.php" class="function">oci_connect()</a></span>, <span class="function"><a href="function.oci-pconnect.php" class="function">oci_pconnect()</a></span>, or <span class="function"><a href="function.oci-new-connect.php" class="function">oci_new_connect()</a></span>.
      </p>
     </dd>
    
   </dl>
  </p>
 </div>


 <div class="refsect1 returnvalues" id="refsect1-function.oci-commit-returnvalues">
  <h3 class="title">Значення, що повертаються</h3>
  <p class="para">
   Повертає <strong><code><a href="reserved.constants.php#constant.true">true</a></code></strong> у разі успіху або <strong><code><a href="reserved.constants.php#constant.false">false</a></code></strong> в разі помилки.
  </p>
 </div>


 <div class="refsect1 examples" id="refsect1-function.oci-commit-examples">
  <h3 class="title">Приклади</h3>
  <p class="para">
   <div class="example" id="example-1">
    <p><strong>Приклад #1 <span class="function"><strong>oci_commit()</strong></span> example</strong></p>
    <div class="example-contents">
<div class="phpcode"><code><span style="color: #000000"><span style="color: #0000BB">&lt;?php<br /><br /></span><span style="color: #FF8000">// Insert into several tables, rolling back the changes if an error occurs<br /><br /></span><span style="color: #0000BB">$conn </span><span style="color: #007700">= </span><span style="color: #0000BB">oci_connect</span><span style="color: #007700">(</span><span style="color: #DD0000">'hr'</span><span style="color: #007700">, </span><span style="color: #DD0000">'welcome'</span><span style="color: #007700">, </span><span style="color: #DD0000">'localhost/XE'</span><span style="color: #007700">);<br /><br /></span><span style="color: #0000BB">$stid </span><span style="color: #007700">= </span><span style="color: #0000BB">oci_parse</span><span style="color: #007700">(</span><span style="color: #0000BB">$conn</span><span style="color: #007700">, </span><span style="color: #DD0000">"INSERT INTO mysalary (id, name) VALUES (1, 'Chris')"</span><span style="color: #007700">);<br /><br /></span><span style="color: #FF8000">// The OCI_NO_AUTO_COMMIT flag tells Oracle not to commit the INSERT immediately<br /></span><span style="color: #0000BB">$r </span><span style="color: #007700">= </span><span style="color: #0000BB">oci_execute</span><span style="color: #007700">(</span><span style="color: #0000BB">$stid</span><span style="color: #007700">, </span><span style="color: #0000BB">OCI_NO_AUTO_COMMIT</span><span style="color: #007700">);<br />if (!</span><span style="color: #0000BB">$r</span><span style="color: #007700">) {    <br />    </span><span style="color: #0000BB">$e </span><span style="color: #007700">= </span><span style="color: #0000BB">oci_error</span><span style="color: #007700">(</span><span style="color: #0000BB">$stid</span><span style="color: #007700">);<br />    </span><span style="color: #0000BB">trigger_error</span><span style="color: #007700">(</span><span style="color: #0000BB">htmlentities</span><span style="color: #007700">(</span><span style="color: #0000BB">$e</span><span style="color: #007700">[</span><span style="color: #DD0000">'message'</span><span style="color: #007700">]), </span><span style="color: #0000BB">E_USER_ERROR</span><span style="color: #007700">);<br />}<br /><br /></span><span style="color: #0000BB">$stid </span><span style="color: #007700">= </span><span style="color: #0000BB">oci_parse</span><span style="color: #007700">(</span><span style="color: #0000BB">$conn</span><span style="color: #007700">, </span><span style="color: #DD0000">'INSERT INTO myschedule (startday) VALUES (12)'</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">$r </span><span style="color: #007700">= </span><span style="color: #0000BB">oci_execute</span><span style="color: #007700">(</span><span style="color: #0000BB">$stid</span><span style="color: #007700">, </span><span style="color: #0000BB">OCI_NO_AUTO_COMMIT</span><span style="color: #007700">);<br />if (!</span><span style="color: #0000BB">$r</span><span style="color: #007700">) {    <br />    </span><span style="color: #0000BB">$e </span><span style="color: #007700">= </span><span style="color: #0000BB">oci_error</span><span style="color: #007700">(</span><span style="color: #0000BB">$stid</span><span style="color: #007700">);<br />    </span><span style="color: #0000BB">oci_rollback</span><span style="color: #007700">(</span><span style="color: #0000BB">$conn</span><span style="color: #007700">);  </span><span style="color: #FF8000">// rollback changes to both tables<br />    </span><span style="color: #0000BB">trigger_error</span><span style="color: #007700">(</span><span style="color: #0000BB">htmlentities</span><span style="color: #007700">(</span><span style="color: #0000BB">$e</span><span style="color: #007700">[</span><span style="color: #DD0000">'message'</span><span style="color: #007700">]), </span><span style="color: #0000BB">E_USER_ERROR</span><span style="color: #007700">);<br />}<br /><br /></span><span style="color: #FF8000">// Commit the changes to both tables<br /></span><span style="color: #0000BB">$r </span><span style="color: #007700">= </span><span style="color: #0000BB">oci_commit</span><span style="color: #007700">(</span><span style="color: #0000BB">$conn</span><span style="color: #007700">);<br />if (!</span><span style="color: #0000BB">$r</span><span style="color: #007700">) {<br />    </span><span style="color: #0000BB">$e </span><span style="color: #007700">= </span><span style="color: #0000BB">oci_error</span><span style="color: #007700">(</span><span style="color: #0000BB">$conn</span><span style="color: #007700">);<br />    </span><span style="color: #0000BB">trigger_error</span><span style="color: #007700">(</span><span style="color: #0000BB">htmlentities</span><span style="color: #007700">(</span><span style="color: #0000BB">$e</span><span style="color: #007700">[</span><span style="color: #DD0000">'message'</span><span style="color: #007700">]), </span><span style="color: #0000BB">E_USER_ERROR</span><span style="color: #007700">);<br />}<br /><br /></span><span style="color: #0000BB">?&gt;</span></span></code></div>
    </div>

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


 <div class="refsect1 notes" id="refsect1-function.oci-commit-notes">
  <h3 class="title">Примітки</h3>
  <blockquote class="note"><p><strong class="note">Зауваження</strong>: 
   <p class="para">
    Transactions are automatically rolled back when you close the
    connection, or when the script ends, whichever is soonest. You
    need to explicitly call <span class="function"><strong>oci_commit()</strong></span> to commit
    the transaction.
   </p>
   <p class="para">
    Any call to <span class="function"><a href="function.oci-execute.php" class="function">oci_execute()</a></span> that uses
    <strong><code><a href="oci8.constants.php#constant.oci-commit-on-success">OCI_COMMIT_ON_SUCCESS</a></code></strong> mode explicitly or by
    default will commit any previous uncommitted transaction.
   </p>
   <p class="para">
    Any Oracle DDL statement such as <code class="literal">CREATE</code>
    or <code class="literal">DROP</code> will automatically commit any
    uncommitted transaction.
   </p>
  </p></blockquote>
 </div>


 <div class="refsect1 seealso" id="refsect1-function.oci-commit-seealso">
  <h3 class="title">Прогляньте також</h3>
  <p class="para">
   <ul class="simplelist">
    <li><span class="function"><a href="function.oci-execute.php" class="function" rel="rdfs-seeAlso">oci_execute()</a> - Executes a statement</span></li>
    <li><span class="function"><a href="function.oci-rollback.php" class="function" rel="rdfs-seeAlso">oci_rollback()</a> - Rolls back the outstanding database transaction</span></li>
   </ul>
  </p>
 </div>


</div><?php manual_footer($setup); ?>