mirror of
https://github.com/fofolee/uTools-Manuals.git
synced 2025-06-18 13:57:03 +08:00
174 lines
7.0 KiB
HTML
174 lines
7.0 KiB
HTML
<!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>将文件导入为大型对象</title>
|
||
</head>
|
||
<body class="docs"><div id="layout">
|
||
<div id="layout-content"><div id="function.pg-lo-import" class="refentry">
|
||
<div class="refnamediv">
|
||
<h1 class="refname">pg_lo_import</h1>
|
||
<p class="verinfo">(PHP 4 >= 4.2.0, PHP 5, PHP 7)</p><p class="refpurpose"><span class="refname">pg_lo_import</span> — <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">resource</span> <code class="parameter">$connection</code></span>
|
||
], <span class="methodparam"><span class="type">string</span> <code class="parameter">$pathname</code></span>
|
||
[, <span class="methodparam"><span class="type"><a href="language.pseudo-types.html#language.types.mixed" class="type mixed">mixed</a></span> <code class="parameter">$object_id</code></span>
|
||
] ) : <span class="type">int</span></div>
|
||
|
||
<p class="para rdfs-comment">
|
||
<span class="function"><strong>pg_lo_import()</strong></span> creates a new large object
|
||
in the database using a file on the filesystem as its data
|
||
source.
|
||
</p>
|
||
<p class="para">
|
||
要使用大型对象(lo)接口,需要将其放置在事务块中。
|
||
</p>
|
||
<blockquote class="note"><p><strong class="note">Note</strong>: <span class="simpara">当启用
|
||
<a href="features.safe_mode.html" class="link">安全模式</a>时,
|
||
PHP 会检查被操作的文件或目录是否与被执行的脚本有相同的 UID(所有者)。</span></p></blockquote>
|
||
<blockquote class="note"><p><strong class="note">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">
|
||
PostgreSQL database connection resource. When
|
||
<code class="parameter">connection</code> is not present, the default connection
|
||
is used. The default connection is the last connection made by
|
||
<span class="function"><a href="pg_connect.html" class="function">pg_connect()</a></span> or <span class="function"><a href="pg_pconnect.html" class="function">pg_pconnect()</a></span>.
|
||
</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">
|
||
If an <code class="parameter">object_id</code> is given the function
|
||
will try to create a large object with this id, else a free
|
||
object id is assigned by the server. The parameter
|
||
was added in PHP 5.3 and relies on functionality that first
|
||
appeared in 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"><var class="varname">OID</var></var>,如果出错则返回 <strong><code>FALSE</code></strong>。
|
||
</p>
|
||
</div>
|
||
|
||
|
||
<div class="refsect1 changelog" id="refsect1-function.pg-lo-import-changelog">
|
||
<h3 class="title">更新日志</h3>
|
||
<p class="para">
|
||
<table class="doctable informaltable">
|
||
|
||
<thead>
|
||
<tr>
|
||
<th>版本</th>
|
||
<th>说明</th>
|
||
</tr>
|
||
|
||
</thead>
|
||
|
||
<tbody class="tbody">
|
||
<tr>
|
||
<td>5.3.0</td>
|
||
<td><p class="para">
|
||
The optional <code class="parameter">object_id</code> was added.
|
||
</p></td>
|
||
</tr>
|
||
|
||
<tr>
|
||
<td>4.2.0</td>
|
||
<td><p class="para">
|
||
在 PHP 4.2.0 版本之前,本函数语法不一样,见如下定义:
|
||
<div class="methodsynopsis dc-description">
|
||
<span class="methodname"><strong>pg_lo_import</strong></span>
|
||
( <span class="methodparam"><span class="type">string</span> <code class="parameter">$pathname</code></span>
|
||
[, <span class="methodparam"><span class="type">resource</span> <code class="parameter">$connection</code></span>
|
||
] ) : <span class="type">int</span></div>
|
||
|
||
</p></td>
|
||
</tr>
|
||
|
||
</tbody>
|
||
|
||
</table>
|
||
|
||
</p>
|
||
</div>
|
||
|
||
|
||
<div class="refsect1 examples" id="refsect1-function.pg-lo-import-examples">
|
||
<h3 class="title">范例</h3>
|
||
<p class="para">
|
||
<div class="example" id="example-2503">
|
||
<p><strong>Example #1 <span class="function"><strong>pg_lo_import()</strong></span> 例子</strong></p>
|
||
<div class="example-contents">
|
||
<div class="phpcode"><pre><span style="color: #000000">
|
||
<span style="color: #0000BB"><?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">?></span>
|
||
</span>
|
||
</pre></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 class="member"><span class="function"><a href="pg_lo_export.html" class="function" rel="rdfs-seeAlso">pg_lo_export()</a> - 将大型对象导出到文件</span></li>
|
||
<li class="member"><span class="function"><a href="pg_lo_open.html" class="function" rel="rdfs-seeAlso">pg_lo_open()</a> - 打开一个大型对象</span></li>
|
||
</ul>
|
||
</p>
|
||
</div>
|
||
|
||
</div></div></div></body></html> |