cvs: peardoc /en/package/database/mdb2 intro-fetch.xml
| From: | Lorenzo Alberton | Date: | Fri, 02 Feb 2007 08:46:24 +0000 |
| Subject: | cvs: peardoc /en/package/database/mdb2 intro-fetch.xml | ||
| Groups: | php.pear.doc | ||
| Request: | Send a blank email to pear-doc+get-9387@lists.php.net to get a copy of this message | ||
quipo Fri Feb 2 08:46:24 2007 UTC
Modified files:
/peardoc/en/package/database/mdb2 intro-fetch.xml
Log:
add paragraph about LOB fetching (bug #9996)
http://cvs.php.net/viewvc.cgi/peardoc/en/package/database/mdb2/intro-fetch.xml?r1=1.28&r2=1.29&diff_format=u
Index: peardoc/en/package/database/mdb2/intro-fetch.xml
diff -u peardoc/en/package/database/mdb2/intro-fetch.xml:1.28
peardoc/en/package/database/mdb2/intro-fetch.xml:1.29
--- peardoc/en/package/database/mdb2/intro-fetch.xml:1.28 Sat Jan 27 00:20:38 2007
+++ peardoc/en/package/database/mdb2/intro-fetch.xml Fri Feb 2 08:46:24 2007
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="iso-8859-1" ?>
-<!-- $Revision: 1.28 $ -->
+<!-- $Revision: 1.29 $ -->
<!--
@@ -283,7 +283,7 @@
<ulink url="http://pear.php.net/package/MDB2/docs/latest/MDB2/MDB2_Result_Common.html#methodgetResource">
<function>getResource</function></ulink> method and then call the
underlying PHP extension directly (though this would of course require that
- it is not upto you to make this sufficiently portable).
+ it is now up to you to make this sufficiently portable).
<example>
<title>Native result resource</title>
<programlisting role="php">
@@ -532,6 +532,54 @@
</para>
</refsect2>
+ <refsect2 id="package.database.mdb2.intro-fetch.desc.lobs">
+ <title>Fetching LOBs</title>
+ <para>
+ To retrieve a Large Object (BLOB or CLOB), you can use streams, as you were reading a file
+ </para>
+
+ <example>
+ <title>
+ Fetching LOBs with streams.
+ </title>
+ <programlisting role="php">
+ <![CDATA[
+<?php
+$result =& $mdb2->query('SELECT document, picture FROM files WHERE id = 1',
array('clob', 'blob'));
+if (PEAR::isError($result) || !$result->valid()) {
+ //uh-oh
+}
+$row = $result->fetchRow();
+
+//fetch the Character LOB into the $clob_value variable
+$clob = $row[0];
+if (!PEAR::isError($clob) && is_resource($clob)) {
+ $clob_value = '';
+ //use streams
+ while (!feof($clob)) {
+ $clob_value .= fread($clob, 8192);
+ }
+ $mdb2->datatype->destroyLOB($clob);
+}
+
+//fetch the Binary LOB into the $blob_value variable
+$blob = $row[1];
+if (!PEAR::isError($blob) && is_resource($blob)) {
+ $blob_value = '';
+ while (!feof($blob)) {
+ $blob_value.= fread($blob, 8192);
+ }
+ $mdb2->datatype->destroyLOB($blob);
+}
+
+//free the result
+$result->free();
+?>
+ ]]>
+ </programlisting>
+ </example>
+ </refsect2>
+
<refsect2 id="package.database.mdb2.intro-fetch.desc.error">
<title>Checking for Errors</title>
<para>