<?php
include_once $_SERVER['DOCUMENT_ROOT'] . '/include/shared-manual.inc';
$TOC = array();
$TOC_DEPRECATED = array();
$PARENTS = array();
include_once dirname(__FILE__) ."/toc/ref.pgsql.inc";
$setup = array (
  'home' => 
  array (
    0 => 'index.php',
    1 => 'PHP Manual',
  ),
  'head' => 
  array (
    0 => 'UTF-8',
    1 => 'en',
  ),
  'this' => 
  array (
    0 => 'function.pg-lo-write.php',
    1 => 'pg_lo_write',
    2 => 'Write to a large object',
  ),
  'up' => 
  array (
    0 => 'ref.pgsql.php',
    1 => 'PostgreSQL Functions',
  ),
  'prev' => 
  array (
    0 => 'function.pg-lo-unlink.php',
    1 => 'pg_lo_unlink',
  ),
  'next' => 
  array (
    0 => 'function.pg-meta-data.php',
    1 => 'pg_meta_data',
  ),
  'alternatives' => 
  array (
  ),
  'source' => 
  array (
    'lang' => 'en',
    'path' => 'reference/pgsql/functions/pg-lo-write.xml',
  ),
  'history' => 
  array (
  ),
);
$setup["toc"] = $TOC;
$setup["toc_deprecated"] = $TOC_DEPRECATED;
$setup["parents"] = $PARENTS;
manual_setup($setup);

contributors($setup);

?>
<div id="function.pg-lo-write" class="refentry">
 <div class="refnamediv">
  <h1 class="refname">pg_lo_write</h1>
  <p class="verinfo">(PHP 4 &gt;= 4.2.0, PHP 5, PHP 7, PHP 8)</p><p class="refpurpose"><span class="refname">pg_lo_write</span> &mdash; <span class="dc-title">Write to a large object</span></p>

 </div>

 <div class="refsect1 description" id="refsect1-function.pg-lo-write-description">
  <h3 class="title">Description</h3>
  <div class="methodsynopsis dc-description">
   <span class="methodname"><strong>pg_lo_write</strong></span>(<span class="methodparam"><span class="type"><a href="class.pgsql-lob.php" class="type PgSql\Lob">PgSql\Lob</a></span> <code class="parameter">$lob</code></span>, <span class="methodparam"><span class="type"><a href="language.types.string.php" class="type string">string</a></span> <code class="parameter">$data</code></span>, <span class="methodparam"><span class="type"><span class="type"><a href="language.types.null.php" class="type null">?</a></span><span class="type"><a href="language.types.integer.php" class="type int">int</a></span></span> <code class="parameter">$length</code><span class="initializer"> = <strong><code><a href="reserved.constants.php#constant.null">null</a></code></strong></span></span>): <span class="type"><span class="type"><a href="language.types.integer.php" class="type int">int</a></span>|<span class="type"><a href="language.types.singleton.php" class="type false">false</a></span></span></div>

  <p class="para rdfs-comment">
   <span class="function"><strong>pg_lo_write()</strong></span> writes data into a large object
   at the current seek position.
  </p>
  <p class="para">
   To use the large object interface, it is necessary to
   enclose it within a transaction block.
  </p>
  <blockquote class="note"><p><strong class="note">Note</strong>: 
   <p class="para">
    This function used to be called <span class="function"><strong>pg_lowrite()</strong></span>.
   </p>
  </p></blockquote>
 </div>


 <div class="refsect1 parameters" id="refsect1-function.pg-lo-write-parameters">
  <h3 class="title">Parameters</h3>
  <p class="para">
   <dl>
    
     <dt><code class="parameter">lob</code></dt>
     <dd>
      <p class="para">An <span class="classname"><a href="class.pgsql-lob.php" class="classname">PgSql\Lob</a></span> instance, returned by <span class="function"><a href="function.pg-lo-open.php" class="function">pg_lo_open()</a></span>.</p>
     </dd>
    
    
     <dt><code class="parameter">data</code></dt>
     <dd>
      <p class="para">
       The data to be written to the large object.  If <code class="parameter">length</code> is
       an <span class="type"><a href="language.types.integer.php" class="type int">int</a></span> and is less than the length of <code class="parameter">data</code>, only
       <code class="parameter">length</code> bytes will be written.
      </p>
     </dd>
    
    
     <dt><code class="parameter">length</code></dt>
     <dd>
      <p class="para">
       An optional maximum number of bytes to write.  Must be greater than zero
       and no greater than the length of <code class="parameter">data</code>.  Defaults to
       the length of <code class="parameter">data</code>.
      </p>
     </dd>
    
   </dl>
  </p>
 </div>


 <div class="refsect1 returnvalues" id="refsect1-function.pg-lo-write-returnvalues">
  <h3 class="title">Return Values</h3>
  <p class="para">
   The number of bytes written to the large object, or <strong><code><a href="reserved.constants.php#constant.false">false</a></code></strong> on error.
  </p>
 </div>


 <div class="refsect1 changelog" id="refsect1-function.pg-lo-write-changelog">
  <h3 class="title">Changelog</h3>
  <table class="doctable informaltable">
   
    <thead>
     <tr>
      <th>Version</th>
      <th>Description</th>
     </tr>

    </thead>

    <tbody class="tbody">
     <tr>
 <td>8.1.0</td>
 <td>
  The <code class="parameter">lob</code> parameter expects an <span class="classname"><a href="class.pgsql-lob.php" class="classname">PgSql\Lob</a></span>
  instance now; previously, a <span class="type"><a href="language.types.resource.php" class="type resource">resource</a></span> was expected.
 </td>
</tr>

     <tr>
      <td>8.0.0</td>
      <td>
       <code class="parameter">length</code> is now nullable.
      </td>
     </tr>

    </tbody>
   
  </table>

 </div>

 
 <div class="refsect1 examples" id="refsect1-function.pg-lo-write-examples">
  <h3 class="title">Examples</h3>
  <p class="para">
   <div class="example" id="example-1">
    <p><strong>Example #1 <span class="function"><strong>pg_lo_write()</strong></span> example</strong></p>
    <div class="example-contents">
<div class="phpcode"><code><span style="color: #000000"><span style="color: #0000BB">&lt;?php<br />   $doc_oid </span><span style="color: #007700">= </span><span style="color: #0000BB">189762345</span><span style="color: #007700">;<br />   </span><span style="color: #0000BB">$data </span><span style="color: #007700">= </span><span style="color: #DD0000">"This will overwrite the start of the large object."</span><span style="color: #007700">;<br />   </span><span style="color: #0000BB">$database </span><span style="color: #007700">= </span><span style="color: #0000BB">pg_connect</span><span style="color: #007700">(</span><span style="color: #DD0000">"dbname=jacarta"</span><span style="color: #007700">);<br />   </span><span style="color: #0000BB">pg_query</span><span style="color: #007700">(</span><span style="color: #0000BB">$database</span><span style="color: #007700">, </span><span style="color: #DD0000">"begin"</span><span style="color: #007700">);<br />   </span><span style="color: #0000BB">$handle </span><span style="color: #007700">= </span><span style="color: #0000BB">pg_lo_open</span><span style="color: #007700">(</span><span style="color: #0000BB">$database</span><span style="color: #007700">, </span><span style="color: #0000BB">$doc_oid</span><span style="color: #007700">, </span><span style="color: #DD0000">"w"</span><span style="color: #007700">);<br />   </span><span style="color: #0000BB">$data </span><span style="color: #007700">= </span><span style="color: #0000BB">pg_lo_write</span><span style="color: #007700">(</span><span style="color: #0000BB">$handle</span><span style="color: #007700">, </span><span style="color: #0000BB">$data</span><span style="color: #007700">);<br />   </span><span style="color: #0000BB">pg_query</span><span style="color: #007700">(</span><span style="color: #0000BB">$database</span><span style="color: #007700">, </span><span style="color: #DD0000">"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-function.pg-lo-write-seealso">
  <h3 class="title">See Also</h3>
  <p class="para">
   <ul class="simplelist">
    <li><span class="function"><a href="function.pg-lo-create.php" class="function" rel="rdfs-seeAlso">pg_lo_create()</a> - Create a large object</span></li>
    <li><span class="function"><a href="function.pg-lo-open.php" class="function" rel="rdfs-seeAlso">pg_lo_open()</a> - Open a large object</span></li>
   </ul>
  </p>
 </div>

</div><?php manual_footer($setup); ?>