<?php
include_once $_SERVER['DOCUMENT_ROOT'] . '/include/shared-manual.inc';
$TOC = array();
$TOC_DEPRECATED = array();
$PARENTS = array();
include_once dirname(__FILE__) ."/toc/class.pdo-pgsql.inc";
$setup = array (
  'home' => 
  array (
    0 => 'index.php',
    1 => 'PHP Manual',
  ),
  'head' => 
  array (
    0 => 'UTF-8',
    1 => 'uk',
  ),
  'this' => 
  array (
    0 => 'pdo-pgsql.lobcreate.php',
    1 => 'Pdo\\Pgsql::lobCreate',
    2 => 'Creates a new large object',
  ),
  'up' => 
  array (
    0 => 'class.pdo-pgsql.php',
    1 => 'Pdo\\Pgsql',
  ),
  'prev' => 
  array (
    0 => 'pdo-pgsql.getpid.php',
    1 => 'Pdo\\Pgsql::getPid',
  ),
  'next' => 
  array (
    0 => 'pdo-pgsql.lobopen.php',
    1 => 'Pdo\\Pgsql::lobOpen',
  ),
  'alternatives' => 
  array (
  ),
  'source' => 
  array (
    'lang' => 'en',
    'path' => 'reference/pdo_pgsql/pdo/pgsql/lobcreate.xml',
  ),
  'history' => 
  array (
  ),
);
$setup["toc"] = $TOC;
$setup["toc_deprecated"] = $TOC_DEPRECATED;
$setup["parents"] = $PARENTS;
manual_setup($setup);

contributors($setup);

?>
<div id="pdo-pgsql.lobcreate" class="refentry">
 <div class="refnamediv">
  <h1 class="refname">Pdo\Pgsql::lobCreate</h1>
  <p class="verinfo">(PHP 8 &gt;= 8.4.0)</p><p class="refpurpose"><span class="refname">Pdo\Pgsql::lobCreate</span> &mdash; <span class="dc-title">Creates a new large object</span></p>

 </div>

 <div class="refsect1 description" id="refsect1-pdo-pgsql.lobcreate-description">
  <h3 class="title">Опис</h3>
  <div class="methodsynopsis dc-description"><span class="modifier">public</span> <span class="methodname"><strong>Pdo\Pgsql::lobCreate</strong></span>(): <span class="type"><span class="type"><a href="language.types.string.php" class="type string">string</a></span>|<span class="type"><a href="language.types.singleton.php" class="type false">false</a></span></span></div>

  <p class="simpara">
   <span class="methodname"><strong>Pdo\Pgsql::lobCreate()</strong></span> creates a large object
   and returns the OID which refers to it.
   It can be opened to read or write data with
   <span class="methodname"><a href="pdo-pgsql.lobopen.php" class="methodname">Pdo\Pgsql::lobOpen()</a></span>.
  </p>
  <p class="simpara">
   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="methodname"><a href="pdo-pgsql.lobunlink.php" class="methodname">Pdo\Pgsql::lobUnlink()</a></span>.
  </p>
  <p class="simpara">
   Large objects are cumbersome to use.
   Indeed, it is required that <span class="methodname"><a href="pdo-pgsql.lobunlink.php" class="methodname">Pdo\Pgsql::lobUnlink()</a></span>
   is called prior to deleting the last row referencing the OID in the entire database;
   otherwise, unreferenced large objects will remain on the server indefinitely.
   Moreover, large objects have no access controls.
   An alternative is the bytea column type, which can be up to 1GB in size,
   and this column type transparently manages the storage for optimal row size.
  </p>
  <blockquote class="note"><p><strong class="note">Зауваження</strong>: 
   <span class="simpara">
    This function, and all manipulations of the large object,
    must be called and carried out within a transaction.
   </span>
  </p></blockquote>
 </div>


 <div class="refsect1 parameters" id="refsect1-pdo-pgsql.lobcreate-parameters">
  <h3 class="title">Параметри</h3>
  <p class="para">У цієї функції немає
параметрів.</p>
 </div>


 <div class="refsect1 returnvalues" id="refsect1-pdo-pgsql.lobcreate-returnvalues">
  <h3 class="title">Значення, що повертаються</h3>
  <p class="simpara">
   Returns the OID of the newly created large object on success,
    або <strong><code><a href="reserved.constants.php#constant.false">false</a></code></strong> в разі помилки.
  </p>
 </div>


 <div class="refsect1 examples" id="refsect1-pdo-pgsql.lobcreate-examples">
  <h3 class="title">Приклади</h3>
  <div class="example" id="pdo-pgsql.lobcreate.example.basic">
   <p><strong>Приклад #1 <span class="methodname"><strong>Pdo\Pgsql::lobCreate()</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 </span><span style="color: #007700">= new </span><span style="color: #0000BB">Pdo\Pgsql</span><span style="color: #007700">(</span><span style="color: #DD0000">'pgsql:dbname=test host=localhost'</span><span style="color: #007700">, </span><span style="color: #0000BB">$user</span><span style="color: #007700">, </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">, </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 </span><span style="color: #007700">= </span><span style="color: #0000BB">$db</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">lobCreate</span><span style="color: #007700">();<br /></span><span style="color: #0000BB">$stream </span><span style="color: #007700">= </span><span style="color: #0000BB">$db</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">lobOpen</span><span style="color: #007700">(</span><span style="color: #0000BB">$oid</span><span style="color: #007700">, </span><span style="color: #DD0000">'w'</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">$local </span><span style="color: #007700">= </span><span style="color: #0000BB">fopen</span><span style="color: #007700">(</span><span style="color: #0000BB">$filename</span><span style="color: #007700">, </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">, </span><span style="color: #0000BB">$stream</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">$local </span><span style="color: #007700">= </span><span style="color: #0000BB">null</span><span style="color: #007700">;<br /></span><span style="color: #0000BB">$stream </span><span style="color: #007700">= </span><span style="color: #0000BB">null</span><span style="color: #007700">;<br /></span><span style="color: #0000BB">$stmt </span><span style="color: #007700">= </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 INTO BLOBS (ident, oid) VALUES (?, ?)"</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">([</span><span style="color: #0000BB">$some_id</span><span style="color: #007700">, </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>
 </div>


 <div class="refsect1 seealso" id="refsect1-pdo-pgsql.lobcreate-seealso">
  <h3 class="title">Прогляньте також</h3>
  <ul class="simplelist">
   <li><span class="methodname"><a href="pdo-pgsql.lobopen.php" class="methodname" rel="rdfs-seeAlso">Pdo\Pgsql::lobOpen()</a> - Opens an existing large object stream</span></li>
   <li><span class="methodname"><a href="pdo-pgsql.lobunlink.php" class="methodname" rel="rdfs-seeAlso">Pdo\Pgsql::lobUnlink()</a> - Deletes the large object</span></li>
   <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>
 </div>


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