<?xml version="1.0" encoding="utf-8"?>
<!-- $Revision$ -->
<!-- Generated by xml_proto.php v2.3. Found in /scripts directory of phpdoc. -->
<refentry xml:id="pdo.pgsqllobopen" xmlns="http://docbook.org/ns/docbook">
 <refnamediv>
  <refname>PDO::pgsqlLOBOpen</refname>
  <refpurpose>Opens an existing large object stream</refpurpose>
 </refnamediv>
 <refsect1 role="description">
  &reftitle.description;
  <methodsynopsis>
   <modifier>public</modifier> <type class="union"><type>resource</type><type>false</type></type><methodname>PDO::pgsqlLOBOpen</methodname>
   <methodparam><type>string</type><parameter>oid</parameter></methodparam>
   <methodparam choice="opt"><type>string</type><parameter>mode</parameter><initializer>"rb"</initializer></methodparam>
  </methodsynopsis>
  <para>
   <function>PDO::pgsqlLOBOpen</function> opens a stream to access the data
   referenced by <parameter>oid</parameter>.  If <parameter>mode</parameter>
   is <literal>r</literal>, the stream is opened for reading, if
   <parameter>mode</parameter> is <literal>w</literal>, then the stream will
   be opened for writing.  You can use all the usual filesystem functions,
   such as <function>fread</function>, <function>fwrite</function> and
   <function>fgets</function> to manipulate the contents of the stream.
  </para>
   <note>
   <simpara>
    This function, and all manipulations of the large object,
    must be called and carried out within a transaction.
   </simpara>
  </note>
</refsect1>
 <refsect1 role="parameters">
  &reftitle.parameters;
  <para>
   <variablelist>
    <varlistentry>
     <term><parameter>oid</parameter></term>
     <listitem>
      <para>
       A large object identifier.
      </para>
     </listitem>
    </varlistentry>
    <varlistentry>
     <term><parameter>mode</parameter></term>
     <listitem>
      <para>
       If mode is <literal>r</literal>, open the stream for reading.
       If mode is <literal>w</literal>, open the stream for writing.
      </para>
     </listitem>
    </varlistentry>
   </variablelist>
  </para>
 </refsect1>
 <refsect1 role="returnvalues">
  &reftitle.returnvalues;
  <para>
   Returns a stream resource on success&return.falseforfailure;.
  </para>
 </refsect1>

 <refsect1 role="examples">
  &reftitle.examples;
  <para>
   <example>
    <title>A <function>PDO::pgsqlLOBOpen</function> example</title>
    <para>
     Following on from the <function>PDO::pgsqlLOBCreate</function>
     example, this code snippet retrieves the large object from
     the database and outputs it to the browser.
    </para>
    <programlisting role="php">
<![CDATA[
<?php
$db = new PDO('pgsql:dbname=test host=localhost', $user, $pass);
$db->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
$db->beginTransaction();
$stmt = $db->prepare("select oid from BLOBS where ident = ?");
$stmt->execute(array($some_id));
$stmt->bindColumn('oid', $oid, PDO::PARAM_STR);
$stmt->fetch(PDO::FETCH_BOUND);
$stream = $db->pgsqlLOBOpen($oid, 'r');
header("Content-type: application/octet-stream");
fpassthru($stream);
?>
]]>
    </programlisting>
   </example>
  </para>
 </refsect1>


 <refsect1 role="seealso">
  &reftitle.seealso;
  <para>
   <simplelist>
    <member><function>PDO::pgsqlLOBCreate</function></member>
    <member><function>PDO::pgsqlLOBUnlink</function></member>
    <member><function>pg_lo_open</function></member>
   </simplelist>
  </para>
 </refsect1>


</refentry>

<!-- Keep this comment at the end of the file
Local variables:
mode: sgml
sgml-omittag:t
sgml-shorttag:t
sgml-minimize-attributes:nil
sgml-always-quote-attributes:t
sgml-indent-step:1
sgml-indent-data:t
indent-tabs-mode:nil
sgml-parent-document:nil
sgml-default-dtd-file:"~/.phpdoc/manual.ced"
sgml-exposed-tags:nil
sgml-local-catalogs:nil
sgml-local-ecat-files:nil
End:
vim600: syn=xml fen fdm=syntax fdl=2 si
vim: et tw=78 syn=sgml
vi: ts=1 sw=1
-->
