Source of: /manual/en/function.sdo-das-relational-applychanges.php
<?php
include_once $_SERVER['DOCUMENT_ROOT'] . '/include/shared-manual.inc';
$TOC = array();
$PARENTS = array();
include_once dirname(__FILE__) ."/toc/ref.sdo.das.rel.inc";
$setup = array (
'home' =>
array (
0 => 'index.php',
1 => 'PHP Manual',
),
'head' =>
array (
0 => 'UTF-8',
1 => 'en',
),
'this' =>
array (
0 => 'function.sdo-das-relational-applychanges.php',
1 => 'SDO_DAS_Relational::applyChanges',
),
'up' =>
array (
0 => 'ref.sdo.das.rel.php',
1 => 'SDO-DAS-Relational Functions',
),
'prev' =>
array (
0 => 'ref.sdo.das.rel.php',
1 => 'SDO-DAS-Relational Functions',
),
'next' =>
array (
0 => 'function.sdo-das-relational-construct.php',
1 => 'SDO_DAS_Relational::__construct',
),
);
$setup["toc"] = $TOC;
$setup["parents"] = $PARENTS;
manual_setup($setup);
manual_header();
?>
<div id="function.sdo-das-relational-applychanges" class="refentry">
<div class="refnamediv">
<h1 class="refname">SDO_DAS_Relational::applyChanges</h1>
<p class="verinfo">(^)</p><p class="refpurpose"><span class="refname">SDO_DAS_Relational::applyChanges</span> — <span class="dc-title">
Applies the changes made to a data graph back to the database.
</span></p>
</div>
<a name="function.sdo-das-relational-applychanges.description"></a><div class="refsect1 description">
<h3 class="title">Description</h3>
<div class="methodsynopsis dc-description">
<span class="type"><span class="type void">void</span></span>
<span class="methodname"><b>SDO_DAS_Relational::applyChanges</b></span>
( <span class="methodparam">
<span class="type"><a href="class.pdo.php" class="type PDO">PDO</a></span>
<tt class="parameter">$database_handle</tt>
</span>
, <span class="methodparam">
<span class="type"><span class="type SDODataObject">SDODataObject</span></span>
<tt class="parameter">$root_data_object</tt>
</span>
)</div>
<div class="warning"><b class="warning">Warning</b><p class="simpara">This function is
<em class="emphasis">EXPERIMENTAL</em>. The behaviour of this function, its name, and
surrounding documentation may change without notice in a future release of PHP.
This function should be used at your own risk.
</p></div>
<p class="para">
Given a PDO database handle and the special root object of a data graph,
examine the change summary in the datagraph and applies the changes
to the database.
The changes that it can apply can be creations of data objects,
deletes of data objects, and modifications to properties of data objects.
</p>
</div>
<a name="function.sdo-das-relational-applychanges.parameters"></a><div class="refsect1 parameters">
<h3 class="title">Parameters</h3>
<p class="para">
</p><dl>
<dt class="varlistentry">
<span class="term">PDO_database_handle</span>
</dt><dd class="listitem">
<p class="para">
Constructed using the PDO extension.
A typical line to construct a PDO database handle might look like this:
</p><div class="example-contents programlisting">
<div class="phpcode"><code><span style="color: #000000">
$dbh = new PDO("mysql:dbname=COMPANYDB;host=localhost",DATABASE_USER,DATABASE_PASSWORD);</span>
</code></div>
</div>
<p>
</p>
</dd>
<dt class="varlistentry">
<span class="term">root_data_object</span>
</dt><dd class="listitem">
<p class="para">
The special root object which is at the top of every SDO data graph.
</p>
</dd>
</dl>
<p>
</p>
</div>
<a name="function.sdo-das-relational-applychanges.returnvalues"></a><div class="refsect1 returnvalues">
<h3 class="title">Return Values</h3>
<p class="para">
None.
Note however that the datagraph that was passed is still intact and usable.
Furthermore, if data objects were created and written back to a
table with autogenerated primary keys,
then those primary keys will now be set in the data objects.
If the changes were successfully written,
then the change summary associated with the datagraph will
have been cleared,
so that it is possible to now make further changes to the
data graph and apply those changes in turn.
In this way it is possible to work with the same data graph
and apply changes repeatedly.
</p>
</div>
<a name="function.sdo-das-relational-applychanges.errors"></a><div class="refsect1 errors">
<h3 class="title">Errors/Exceptions</h3>
<p class="para">
<b>SDO_DAS_Relational::applyChanges()</b>
can throw an SDO_DAS_Relational_Exception if it is
unable to apply all the changes correctly.
</p>
<p class="para">
The Relational DAS starts a database transaction before
beginning to apply the changes and will commit
the transaction only if they are all successful.
The Relational DAS generates qualified update and delete statements
which contain a where clause that specifies that the row to be
updated or deleted must contain the same values that it did
when the data was first retrieved.
This is how the optimistic concurrency is implemented.
If any of the qualified update or delete statements fails to update or
delete their target row, it may be because the data has been altered
in the database in the meantime.
In any event, if any update fails for any reason,
the transaction is rolled back and an exception thrown.
The exception will contain the generated SQL statement that failed.
</p>
<p class="para">
The Relational DAS also catches any PDO exceptions and obtains PDO
diagnostic information which it includes in an
SDO_DAS_Relational_Exception which it then throws.
</p>
</div>
<a name="function.sdo-das-relational-applychanges.examples"></a><div class="refsect1 examples">
<h3 class="title">Examples</h3>
<p class="para">
Please see the
<a href="sdo.das.rel.examples.php" class="link">Examples</a>
section in the general information about the Relational DAS
for many examples of calling this method.
Please see also the section on
<a href="sdodasrel.configuration.php#sdo.das.rel.tracing" class="link">Tracing</a>
to see how you can see what SQL statements are
generated by the Relational DAS.
</p>
</div>
</div><?php manual_footer(); ?>