<?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 => 'zh',
  ),
  'this' => 
  array (
    0 => 'function.pg-lo-import.php',
    1 => 'pg_lo_import',
    2 => '将文件导入为大型对象',
  ),
  'up' => 
  array (
    0 => 'ref.pgsql.php',
    1 => 'PostgreSQL 函数',
  ),
  'prev' => 
  array (
    0 => 'function.pg-lo-export.php',
    1 => 'pg_lo_export',
  ),
  'next' => 
  array (
    0 => 'function.pg-lo-open.php',
    1 => 'pg_lo_open',
  ),
  'alternatives' => 
  array (
  ),
  'source' => 
  array (
    'lang' => 'zh',
    'path' => 'reference/pgsql/functions/pg-lo-import.xml',
  ),
  'history' => 
  array (
  ),
);
$setup["toc"] = $TOC;
$setup["toc_deprecated"] = $TOC_DEPRECATED;
$setup["parents"] = $PARENTS;
manual_setup($setup);

contributors($setup);

?>
<div id="function.pg-lo-import" class="refentry">
 <div class="refnamediv">
  <h1 class="refname">pg_lo_import</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_import</span> &mdash; <span class="dc-title">将文件导入为大型对象</span></p>

 </div>

 <div class="refsect1 description" id="refsect1-function.pg-lo-import-description">
  <h3 class="title">说明</h3>
  <div class="methodsynopsis dc-description">
   <span class="methodname"><strong>pg_lo_import</strong></span>(<span class="methodparam"><span class="type"><a href="class.pgsql-connection.php" class="type PgSql\Connection">PgSql\Connection</a></span> <code class="parameter">$connection</code><span class="initializer"> = ?</span></span>, <span class="methodparam"><span class="type"><a href="language.types.string.php" class="type string">string</a></span> <code class="parameter">$pathname</code></span>, <span class="methodparam"><span class="type"><a href="language.types.mixed.php" class="type mixed">mixed</a></span> <code class="parameter">$object_id</code><span class="initializer"> = ?</span></span>): <span class="type">int|string|false</span></div>

  <p class="para rdfs-comment">
   <span class="function"><strong>pg_lo_import()</strong></span> 使用文件系统上的文件作为其数据源从而在数据库中创建新的大对象。
  </p>
  <p class="para">
    要使用大型对象接口，需要将其放置在事务块中。
  </p>
  <blockquote class="note"><p><strong class="note">注意</strong>: 
   <p class="para">
    本函数以前的名字为 <span class="function"><strong>pg_loimport()</strong></span>。
   </p>
  </p></blockquote>
 </div>


 <div class="refsect1 parameters" id="refsect1-function.pg-lo-import-parameters">
  <h3 class="title">参数</h3>
  <p class="para">
   <dl>
    
     <dt><code class="parameter">connection</code></dt>
     <dd>
      <p class="para">An <span class="classname"><a href="class.pgsql-connection.php" class="classname">PgSql\Connection</a></span> instance.
When <code class="parameter">connection</code> is unspecified, the default connection is used.
The default connection is the last connection made by <span class="function"><a href="function.pg-connect.php" class="function">pg_connect()</a></span>
or <span class="function"><a href="function.pg-pconnect.php" class="function">pg_pconnect()</a></span>.
<div class="warning"><strong class="warning">警告</strong><p class="simpara">As of PHP 8.1.0, using the default connection is deprecated.</p></div></p>
     </dd>
    
    
     <dt><code class="parameter">pathname</code></dt>
     <dd>
      <p class="para">
       在客户端文件系统上读取大对象数据的文件的完整路径和文件名。
      </p>
     </dd>
    
    
     <dt><code class="parameter">object_id</code></dt>
     <dd>
      <p class="para">
       如果指定了 <code class="parameter">object_id</code>，该函数将使用此 id
       尝试创建大对象，否则服务器将分配空闲对象 id。该参数依赖于 PostgreSQL 8.1 中首次出现的功能。
      </p>
     </dd>
    
   </dl>
  </p>
 </div>


 <div class="refsect1 returnvalues" id="refsect1-function.pg-lo-import-returnvalues">
  <h3 class="title">返回值</h3>
  <p class="para">
   新创建大对象的 <var class="varname">OID</var>， 或者在失败时返回 <strong><code><a href="reserved.constants.php#constant.false">false</a></code></strong>。
  </p>
 </div>


 <div class="refsect1 changelog" id="refsect1-function.pg-lo-import-changelog">
  <h3 class="title">更新日志</h3>
  <table class="doctable informaltable">
   
    <thead>
     <tr>
      <th>版本</th>
      <th>说明</th>
     </tr>

    </thead>

    <tbody class="tbody">
     <tr>
 <td>8.1.0</td>
 <td>
  现在 <code class="parameter">connection</code> 参数接受 <span class="classname"><a href="class.pgsql-connection.php" class="classname">PgSql\Connection</a></span>
  实例，之前接受 <span class="type"><a href="language.types.resource.php" class="type resource">resource</a></span>。
 </td>
</tr>

    </tbody>
   
  </table>

 </div>


 <div class="refsect1 examples" id="refsect1-function.pg-lo-import-examples">
  <h3 class="title">示例</h3>
  <p class="para">
   <div class="example" id="example-1">
    <p><strong>示例 #1 <span class="function"><strong>pg_lo_import()</strong></span> 示例</strong></p>
    <div class="example-contents">
<div class="phpcode"><code><span style="color: #000000"><span style="color: #0000BB">&lt;?php<br />   $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">$oid </span><span style="color: #007700">= </span><span style="color: #0000BB">pg_lo_import</span><span style="color: #007700">(</span><span style="color: #0000BB">$database</span><span style="color: #007700">, </span><span style="color: #DD0000">'/tmp/lob.dat'</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-import-seealso">
  <h3 class="title">参见</h3>
  <p class="para">
   <ul class="simplelist">
    <li><span class="function"><a href="function.pg-lo-export.php" class="function" rel="rdfs-seeAlso">pg_lo_export()</a> - 将大型对象导出到文件</span></li>
    <li><span class="function"><a href="function.pg-lo-open.php" class="function" rel="rdfs-seeAlso">pg_lo_open()</a> - 打开大对象</span></li>
   </ul>
  </p>
 </div>

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