Sophie

Sophie

distrib > Mageia > 4 > i586 > by-pkgid > f800694edefe91adea2624f711a41a2d > files > 10195

php-manual-en-5.5.7-1.mga4.noarch.rpm

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
 <head>
  <meta http-equiv="content-type" content="text/html; charset=UTF-8">
  <title>Creates a new large object</title>

 </head>
 <body><div class="manualnavbar" style="text-align: center;">
 <div class="prev" style="text-align: left; float: left;"><a href="ref.pdo-pgsql.connection.html">PDO_PGSQL DSN</a></div>
 <div class="next" style="text-align: right; float: right;"><a href="pdo.pgsqllobopen.html">PDO::pgsqlLOBOpen</a></div>
 <div class="up"><a href="ref.pdo-pgsql.html">PostgreSQL (PDO)</a></div>
 <div class="home"><a href="index.html">PHP Manual</a></div>
</div><hr /><div id="pdo.pgsqllobcreate" class="refentry">
 <div class="refnamediv">
  <h1 class="refname">PDO::pgsqlLOBCreate</h1>
  <p class="verinfo">(PHP 5 &gt;= 5.1.2, PECL pdo_pgsql &gt;= 1.0.2)</p><p class="refpurpose"><span class="refname">PDO::pgsqlLOBCreate</span> &mdash; <span class="dc-title">Creates a new large object</span></p>

 </div>
 <div class="refsect1 description" id="refsect1-pdo.pgsqllobcreate-description">
  <h3 class="title">Description</h3>
  <div class="methodsynopsis dc-description">
   <span class="modifier">public</span> <span class="type">string</span> <span class="methodname"><strong>PDO::pgsqlLOBCreate</strong></span>
    ( <span class="methodparam">void</span>
   )</div>

  <p class="para rdfs-comment">
    <span class="function"><strong>PDO::pgsqlLOBCreate()</strong></span> creates a large object and
   returns the OID of that object.  You may then open a stream on the object
   using  <span class="function"><a href="pdo.pgsqllobopen.html" class="function">PDO::pgsqlLOBOpen()</a></span> 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  <span class="function"><a href="pdo.pgsqllobunlink.html" class="function">PDO::pgsqlLOBUnlink()</a></span>.
  </p>
  <p class="para">
   Large objects can be up to 2GB in size, but are cumbersome to use; you need
   to ensure that  <span class="function"><a href="pdo.pgsqllobunlink.html" class="function">PDO::pgsqlLOBUnlink()</a></span> 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.
  </p>
  <blockquote class="note"><p><strong class="note">Note</strong>: 
   <span class="simpara">
    This function must be called within a transaction.
   </span>
  </p></blockquote>
 </div>

 <div class="refsect1 parameters" id="refsect1-pdo.pgsqllobcreate-parameters">
  <h3 class="title">Parameters</h3>
  <p class="para">
    <span class="function"><strong>PDO::pgsqlLOBCreate()</strong></span> takes no parameters.
  </p>
 </div>


 <div class="refsect1 returnvalues" id="refsect1-pdo.pgsqllobcreate-returnvalues">
  <h3 class="title">Return Values</h3>
  <p class="para">
   Returns the OID of the newly created large object on success, or <strong><code>FALSE</code></strong>
   on failure.
  </p>
 </div>

 
 <div class="refsect1 examples" id="refsect1-pdo.pgsqllobcreate-examples">
  <h3 class="title">Examples</h3>
  <p class="para">
   <div class="example" id="example-986">
    <p><strong>Example #1 A  <span class="function"><strong>PDO::pgsqlLOBCreate()</strong></span> example</strong></p>
    <div class="example-contents"><p>
     This example creates a new large object and copies the contents
     of a file into it.  The OID is then stored into a table.
    </p></div>
    <div class="example-contents">
<div class="phpcode"><code><span style="color: #000000">
<span style="color: #0000BB">&lt;?php<br />$db&nbsp;</span><span style="color: #007700">=&nbsp;new&nbsp;</span><span style="color: #0000BB">PDO</span><span style="color: #007700">(</span><span style="color: #DD0000">'pgsql:dbname=test&nbsp;host=localhost'</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">$user</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">$pass</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">$db</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">setAttribute</span><span style="color: #007700">(</span><span style="color: #0000BB">PDO</span><span style="color: #007700">::</span><span style="color: #0000BB">ATTR_ERRMODE</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">PDO</span><span style="color: #007700">::</span><span style="color: #0000BB">ERRMODE_EXCEPTION</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">$db</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">beginTransaction</span><span style="color: #007700">();<br /></span><span style="color: #0000BB">$oid&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">$db</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">pgsqlLOBCreate</span><span style="color: #007700">();<br /></span><span style="color: #0000BB">$stream&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">$db</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">pgsqlLOBOpen</span><span style="color: #007700">(</span><span style="color: #0000BB">$oid</span><span style="color: #007700">,&nbsp;</span><span style="color: #DD0000">'w'</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">$local&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">fopen</span><span style="color: #007700">(</span><span style="color: #0000BB">$filename</span><span style="color: #007700">,&nbsp;</span><span style="color: #DD0000">'rb'</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">stream_copy_to_stream</span><span style="color: #007700">(</span><span style="color: #0000BB">$local</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">$stream</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">$local&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">null</span><span style="color: #007700">;<br /></span><span style="color: #0000BB">$stream&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">null</span><span style="color: #007700">;<br /></span><span style="color: #0000BB">$stmt&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">$db</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">prepare</span><span style="color: #007700">(</span><span style="color: #DD0000">"INSERT&nbsp;INTO&nbsp;BLOBS&nbsp;(ident,&nbsp;oid)&nbsp;VALUES&nbsp;(?,&nbsp;?)"</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">$stmt</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">execute</span><span style="color: #007700">(array(</span><span style="color: #0000BB">$some_id</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">$oid</span><span style="color: #007700">));<br /></span><span style="color: #0000BB">$db</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">commit</span><span style="color: #007700">();<br /></span><span style="color: #0000BB">?&gt;</span>
</span>
</code></div>
    </div>

   </div>
  </p>
 </div>



 <div class="refsect1 seealso" id="refsect1-pdo.pgsqllobcreate-seealso">
  <h3 class="title">See Also</h3>
  <p class="para">
   <ul class="simplelist">
    <li class="member"> <span class="function"><a href="pdo.pgsqllobopen.html" class="function" rel="rdfs-seeAlso">PDO::pgsqlLOBOpen()</a> - Opens an existing large object stream</span></li>
    <li class="member"> <span class="function"><a href="pdo.pgsqllobunlink.html" class="function" rel="rdfs-seeAlso">PDO::pgsqlLOBUnlink()</a> - Deletes the large object</span></li>
    <li class="member"> <span class="function"><a href="function.pg-lo-create.html" class="function" rel="rdfs-seeAlso">pg_lo_create()</a> - Create a large object</span></li>
   </ul>
  </p>
 </div>



</div><hr /><div class="manualnavbar" style="text-align: center;">
 <div class="prev" style="text-align: left; float: left;"><a href="ref.pdo-pgsql.connection.html">PDO_PGSQL DSN</a></div>
 <div class="next" style="text-align: right; float: right;"><a href="pdo.pgsqllobopen.html">PDO::pgsqlLOBOpen</a></div>
 <div class="up"><a href="ref.pdo-pgsql.html">PostgreSQL (PDO)</a></div>
 <div class="home"><a href="index.html">PHP Manual</a></div>
</div></body></html>