FAQ
sixd Wed, 19 Mar 2014 19:06:27 +0000

Revision: http://svn.php.net/viewvc?view=revision&revision=333038

Log:
Add common use case example; mention oci_fetch_all mode exclusivity; add notes about LOB peak memory usage.

Changed paths:
     U phpdoc/en/trunk/reference/oci8/examples.xml
     U phpdoc/en/trunk/reference/oci8/functions/oci-bind-by-name.xml
     U phpdoc/en/trunk/reference/oci8/functions/oci-fetch-all.xml
     U phpdoc/en/trunk/reference/oci8/functions/oci-fetch-array.xml

Modified: phpdoc/en/trunk/reference/oci8/examples.xml
===================================================================
--- phpdoc/en/trunk/reference/oci8/examples.xml 2014-03-19 15:18:15 UTC (rev 333037)
+++ phpdoc/en/trunk/reference/oci8/examples.xml 2014-03-19 19:06:27 UTC (rev 333038)
@@ -107,8 +107,47 @@
   </example>

   <example>
- <title>Inserting data into a CLOB column</title>
+ <title>Binding in the WHERE clause of a query</title>
    <para>
+ This shows a single scalar bind.
+ </para>
+ <programlisting role="php">
+<![CDATA[
+<?php
+
+$conn = oci_connect("hr", "hrpwd", "localhost/XE");
+if (!$conn) {
+ $m = oci_error();
+ trigger_error(htmlentities($m['message']), E_USER_ERROR);
+}
+
+$sql = 'SELECT last_name FROM employees WHERE department_id = :didbv ORDER BY last_name';
+$stid = oci_parse($conn, $sql);
+$didbv = 60;
+oci_bind_by_name($stid, ':didbv', $didbv);
+oci_execute($stid);
+while (($row = oci_fetch_array($stid, OCI_ASSOC)) != false) {
+ echo $row['LAST_NAME'] ."<br>\n";
+}
+
+// Output is
+// Austin
+// Ernst
+// Hunold
+// Lorentz
+// Pataballa
+
+oci_free_statement($stid);
+oci_close($conn);
+
+?>
+]]>
+ </programlisting>
+ </example>
+
+ <example>
+ <title>Inserting and fetching a CLOB</title>
+ <para>
     For large data use binary long object (BLOB) or character long
     object (CLOB) types. This example uses CLOB.
    </para>
@@ -149,9 +188,10 @@
  oci_execute($stid);

  print '<table border="1">';
-while ($row = oci_fetch_array($stid, OCI_ASSOC)) {
- $result = $row['MYCLOB']->load();
- print '<tr><td>'.$result.'</td></tr>';
+while ($row = oci_fetch_array($stid, OCI_ASSOC+OCI_RETURN_LOBS)) {
+ print '<tr><td>'.$row['MYCLOB'].'</td></tr>';
+ // In a loop, freeing the large variable before the 2nd fetch reduces PHP's peak memory usage
+ unset($row);
  }
  print '</table>';


Modified: phpdoc/en/trunk/reference/oci8/functions/oci-bind-by-name.xml
===================================================================
--- phpdoc/en/trunk/reference/oci8/functions/oci-bind-by-name.xml 2014-03-19 15:18:15 UTC (rev 333037)
+++ phpdoc/en/trunk/reference/oci8/functions/oci-bind-by-name.xml 2014-03-19 19:06:27 UTC (rev 333038)
@@ -366,16 +366,21 @@
      trigger_error(htmlentities($m['message']), E_USER_ERROR);
  }

-$sql = 'SELECT last_name FROM employees WHERE employee_id = :eidbv';
+$sql = 'SELECT last_name FROM employees WHERE department_id = :didbv ORDER BY last_name';
  $stid = oci_parse($conn, $sql);
-$myeid = 101;
-oci_bind_by_name($stid, ':eidbv', $myeid);
+$didbv = 60;
+oci_bind_by_name($stid, ':didbv', $didbv);
  oci_execute($stid);
-$row = oci_fetch_array($stid, OCI_ASSOC);
-echo $row['LAST_NAME'] ."<br>\n";
+while (($row = oci_fetch_array($stid, OCI_ASSOC)) != false) {
+ echo $row['LAST_NAME'] ."<br>\n";
+}

  // Output is
-// Kochhar
+// Austin
+// Ernst
+// Hunold
+// Lorentz
+// Pataballa

  oci_free_statement($stid);
  oci_close($conn);
@@ -746,9 +751,10 @@
  oci_execute($stid);

  print '<table border="1">';
-while ($row = oci_fetch_array($stid, OCI_ASSOC)) {
- $result = $row['MYCLOB']->load();
- print '<tr><td>'.$result.'</td></tr>';
+while ($row = oci_fetch_array($stid, OCI_ASSOC+OCI_RETURN_LOBS)) {
+ print '<tr><td>'.$row['MYCLOB'].'</td></tr>';
+ // In a loop, freeing the large variable before the 2nd fetch reduces PHP's peak memory usage
+ unset($row);
  }
  print '</table>';


Modified: phpdoc/en/trunk/reference/oci8/functions/oci-fetch-all.xml
===================================================================
--- phpdoc/en/trunk/reference/oci8/functions/oci-fetch-all.xml 2014-03-19 15:18:15 UTC (rev 333037)
+++ phpdoc/en/trunk/reference/oci8/functions/oci-fetch-all.xml 2014-03-19 19:06:27 UTC (rev 333038)
@@ -102,7 +102,8 @@
         </table>
        </para>
        <para>
- Arrays can be indexed by column heading or numerically.
+ Arrays can be indexed either by column heading or numerically.
+ Only one index mode will be returned.
         <table>
          <title><function>oci_fetch_all</function> Array Index Modes</title>
          <tgroup cols="2">

Modified: phpdoc/en/trunk/reference/oci8/functions/oci-fetch-array.xml
===================================================================
--- phpdoc/en/trunk/reference/oci8/functions/oci-fetch-array.xml 2014-03-19 15:18:15 UTC (rev 333037)
+++ phpdoc/en/trunk/reference/oci8/functions/oci-fetch-array.xml 2014-03-19 19:06:27 UTC (rev 333038)
@@ -324,6 +324,8 @@
  while (($row = oci_fetch_array($stid, OCI_ASSOC+OCI_RETURN_LOBS)) != false) {
      echo $row['ID'] . "<br>\n";
      echo $row['DESCRIPTION'] . "<br>\n"; // this contains all of DESCRIPTION
+ // In a loop, freeing the large variable before the 2nd fetch reduces PHP's peak memory usage
+ unset($row);
  }

  // Output is:
@@ -594,7 +596,7 @@
  // Requires OCI8 2.0 and Oracle Database 12c
  // Also see oci_get_implicit_resultset()
  $sql = 'DECLARE
- c1 SYS_REFCURSOR;
+ c1 SYS_REFCURSOR;
          BEGIN
             OPEN c1 FOR SELECT city, postal_code FROM locations WHERE ROWNUM < 4 ORDER BY city;
             DBMS_SQL.RETURN_RESULT(c1);

Search Discussions

Related Discussions

Discussion Navigation
viewthread | post
posts ‹ prev | 1 of 1 | next ›
Discussion Overview
groupphp-doc-cvs @
categoriesphp
postedMar 19, '14 at 7:06p
activeMar 19, '14 at 7:06p
posts1
users1
websitephp.net

1 user in discussion

Christopher Jones: 1 post

People

Translate

site design / logo © 2019 Grokbase