⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 function.pdo-pgsqllobcreate.html

📁 php的帮助文档,涉及到PHP的案例和基本语法,以及实际应用内容
💻 HTML
字号:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"><html> <head>  <title>Creates a new large object</title>  <meta http-equiv="content-type" content="text/html; charset=UTF-8"> </head> <body><div 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="function.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="function.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:1.0.1-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">  <h3 class="title">Description</h3>  <div class="methodsynopsis dc-description">   <span class="type">string</span> <span class="methodname"><b><b>PDO::pgsqlLOBCreate</b></b></span>    ( <span class="methodparam">void</span>   )</div>  <p class="para rdfs-comment">   <b>PDO::pgsqlLOBCreate()</b> creates a large object and   returns the OID of that object.  You may then open a stream on the object   using <a href="function.pdo-pgsqllobopen.html" class="function">PDO::pgsqlLOBOpen()</a> 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 <a href="function.pdo-pgsqllobunlink.html" class="function">PDO::pgsqlLOBUnlink()</a>.  </p>  <p class="para">   Large objects can be up to 2GB in size, but are cumbersome to use; you need   to ensure that <a href="function.pdo-pgsqllobunlink.html" class="function">PDO::pgsqlLOBUnlink()</a> 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><p><b class="note">Note</b>:    <span class="simpara">    This function must be called within a transaction.   </span>  </p></blockquote> </div> <div class="refsect1 parameters">  <h3 class="title">Parameters</h3>  <p class="para">   <b>PDO::pgsqlLOBCreate()</b> takes no parameters.  </p> </div> <div class="refsect1 returnvalues">  <h3 class="title">Return Values</h3>  <p class="para">   Returns the OID of the newly created large object on success, or <b><tt>FALSE</tt></b>   on failure.  </p> </div>  <div class="refsect1 examples">  <h3 class="title">Examples</h3>  <p class="para">   <div class="example">    <p><b>Example #1 A <b>PDO::pgsqlLOBCreate()</b> example</b></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">  <h3 class="title">See Also</h3>  <p class="para">   <ul class="simplelist">    <li class="member"><a href="function.pdo-pgsqllobopen.html" class="function" rel="rdfs-seeAlso">PDO::pgsqlLOBOpen()</a></li>    <li class="member"><a href="function.pdo-pgsqllobunlink.html" class="function" rel="rdfs-seeAlso">PDO::pgsqlLOBUnlink()</a></li>    <li class="member"><a href="function.pg-lo-create.html" class="function" rel="rdfs-seeAlso">pg_lo_create()</a></li>   </ul>  </p> </div></div><hr /><div 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="function.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>

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -