cvs: phpdoc /en/reference/sdodasrel/functions SDO-DAS-Relational-executePreparedQuery.xml
| From: | Matthew Peters | Date: | Mon, 01 Aug 2005 09:23:02 +0000 |
| Subject: | cvs: phpdoc /en/reference/sdodasrel/functions SDO-DAS-Relational-executePreparedQuery.xml | ||
| Groups: | php.doc | ||
| Request: | Send a blank email to phpdoc+get-969369418@lists.php.net to get a copy of this message | ||
mfp Mon Aug 1 05:23:02 2005 EDT
Modified files:
/phpdoc/en/reference/sdodasrel/functions
SDO-DAS-Relational-executePreparedQuery.xml
Log:
Add <programlisting> with example code for executePreparedQuery()
http://cvs.php.net/diff.php/phpdoc/en/reference/sdodasrel/functions/SDO-DAS-Relational-executePreparedQuery.xml?r1=1.1&r2=1.2&ty=u
Index: phpdoc/en/reference/sdodasrel/functions/SDO-DAS-Relational-executePreparedQuery.xml
diff -u phpdoc/en/reference/sdodasrel/functions/SDO-DAS-Relational-executePreparedQuery.xml:1.1
phpdoc/en/reference/sdodasrel/functions/SDO-DAS-Relational-executePreparedQuery.xml:1.2
--- phpdoc/en/reference/sdodasrel/functions/SDO-DAS-Relational-executePreparedQuery.xml:1.1 Fri Jul
29 14:14:31 2005
+++ phpdoc/en/reference/sdodasrel/functions/SDO-DAS-Relational-executePreparedQuery.xml Mon Aug 1
05:23:02 2005
@@ -1,5 +1,5 @@
<?xml version='1.0' encoding='iso-8859-1'?>
-<!-- $Revision: 1.1 $ -->
+<!-- $Revision: 1.2 $ -->
<refentry id="function.SDO-DAS-Relational-executePreparedQuery">
<refnamediv>
<refname>SDO_DAS_Relational::executePreparedQuery</refname>
@@ -196,10 +196,63 @@
<refsect1 role="examples">
&reftitle.examples;
<para>
- Please see the
- <link linkend='sdo.das.rel.examples'>Examples</link>
- section in the general information about the
- Relational DAS for many examples of calling this method.
+ <example>
+ <title>Retrieving a data object using executePreparedQuery</title>
+ <para>
+ In this example a single data object is retrieved from the database
+ - or possibly more than one if there is more than one company
+ called 'Acme'. For each company returned, the
+ <varname>name</varname>
+ and
+ <varname>id</varname>
+ properties are echoed.
+ </para>
+ <para>
+ Other examples of the use of
+ <function>executePreparedQuery</function>
+ can be found in the example code supplied in
+ <filename>sdo/DAS/Relational/Scenarios</filename>
+ .
+ </para>
+ <programlisting role="php" id="sdo.das.rel.functions.epq.1c-R">
+<![CDATA[
+<?php
+require_once 'SDO/DAS/Relational.php';
+require_once 'company_metadata.inc.php';
+
+/**************************************************************
+ * Construct the DAS with the metadata
+ ***************************************************************/
+$das = new SDO_DAS_Relational ($database_metadata,'company',$SDO_reference_metadata);
+
+/**************************************************************
+ * Get a database connection
+ ***************************************************************/
+$dbh = new PDO(PDO_DSN,DATABASE_USER,DATABASE_PASSWORD);
+
+/**************************************************************
+ * Issue a query to obtain a company object - possibly more if they exist
+ * Use a prepared query with a placeholder.
+ ***************************************************************/
+$name = 'Acme';
+$pdo_stmt = $dbh->prepare('select name, id from company where name=?');
+$root = $das->executePreparedQuery(
+ $dbh,
+ $pdo_stmt,
+ array($name),
+ array('company.name', 'company.id'));
+
+/**************************************************************
+ * Echo name and id
+ ***************************************************************/
+foreach ($root['company'] as $company) {
+ echo "Company obtained from the database has name = " .
+ $company['name'] . " and id " . $company['id'] . "\n";
+}
+?>
+]]>
+ </programlisting>
+ </example>
</para>
</refsect1>
</refentry>