php-doc-en/reference/pdo_pgsql/functions/PDO-pgsqlLOBCreate.xml
Jean-Sébastien Goupil 96bd406a66 simplify refpurpose + correcting see also
git-svn-id: https://svn.php.net/repository/phpdoc/en/trunk@201992 c90b9560-bf6c-de11-be94-00142212c4b1
2005-12-04 08:45:01 +00:00

119 lines
3.5 KiB
XML

<?xml version="1.0" encoding="iso-8859-1"?>
<!-- $Revision: 1.2 $ -->
<!-- Generated by xml_proto.php v2.3. Found in /scripts directory of phpdoc. -->
<refentry id="function.PDO-pgsqlLOBCreate">
<refnamediv>
<refname>PDO::pgsqlLOBCreate</refname>
<refpurpose>Creates a new large object</refpurpose>
</refnamediv>
<refsect1 role="description">
&reftitle.description;
<methodsynopsis>
<type>string</type><methodname>PDO::pgsqlLOBCreate</methodname>
<void/>
</methodsynopsis>
<para>
<function>PDO::pgsqlLOBCreate</function> creates a large object and
returns the OID of that object. You may then open a stream on the object
using <function>PDO::pgsqlLOBOpen</function> to read or write data to
it. The OID can be stored in columns of type OID and be used to reference
the large object, without causing the row to grow arbitrarily large.
The large object will continue to live in the database until it
is removed by calling <function>PDO::pgsqlLOBUnlink</function>.
</para>
<para>
Large objects can be up to 2GB in size, but are cumbersome to use; you need
to ensure that <function>PDO::pgsqlLOBUnlink</function> is called prior
to deleting the last row that references its OID from your database.
In addition, large objects have no access controls. As an alternative,
try the bytea column type; recent versions of PostgreSQL allow bytea
columns of up to 1GB in size and transparently manage the storage for
optimal row size.
</para>
<note>
<simpara>
This function must be called within a transaction.
</simpara>
</note>
</refsect1>
<refsect1 role="parameters">
&reftitle.parameters;
<para>
<function>PDO::pgsqlLOBCreate</function> takes no parameters.
</para>
</refsect1>
<refsect1 role="returnvalues">
&reftitle.returnvalues;
<para>
Returns the OID of the newly created large object on success, or &false;
on failure.
</para>
</refsect1>
<refsect1 role="examples">
&reftitle.examples;
<para>
<example>
<title>A <function>PDO::pgsqlLOBCreate</function> example</title>
<para>
This example creates a new large object and copies the contents
of a file into it. The OID is then stored into a table.
</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();
$oid = $db->pgsqlLOBCreate();
$stream = $db->pgsqlLOBOpen($oid, 'w');
$local = fopen($filename, 'rb');
stream_copy_to_stream($local, $stream);
$local = null;
$stream = null;
$stmt = $db->prepare("INSERT INTO BLOBS (ident, oid) VALUES (?, ?)");
$stmt->execute(array($some_id, $oid));
$db->commit();
?>
]]>
</programlisting>
</example>
</para>
</refsect1>
<refsect1 role="seealso">
&reftitle.seealso;
<para>
<simplelist>
<member><function>PDO::pgsqlLOBOpen</function></member>
<member><function>PDO::pgsqlLOBUnlink</function></member>
<member><function>pg_lo_create</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:"../../../../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
-->