Deprecated: The each() function is deprecated. This message will be suppressed on further calls in /home/zhenxiangba/zhenxiangba.com/public_html/phproxy-improved-master/index.php on line 456
PHP: pg_lo_write - Manual
[go: Go Back, main page]

PHP  
downloads | documentation | faq | getting help | mailing lists | reporting bugs | php.net sites | links | my php.net 
search for in the  
<pg_lo_unlinkpg_meta_data" width="11" height="7"/>
view the version of this page
Last updated: Sun, 07 May 2006

pg_lo_write

(PHP 4 >= 4.2.0, PHP 5)

pg_lo_write -- ラージオブジェクトを書く

説明

int pg_lo_write ( resource large_object, string data [, int len] )

pg_lo_write() は、ラージオブジェクトの カレントのシーク位置にデータを書き込みます。

ラージオブジェクトインターフェースは、トランザクションブロックの中で 使用する必要があります。

注意: この関数は、以前は pg_lowrite() と呼ばれていました。

パラメータ

large_object

pg_lo_open() によって返された PostgreSQL ラージオブジェクト (LOB) リソース。

data

ラージオブジェクトに書き込むデータ。lendata の長さより小さく指定されている場合、 len バイトのみが書き込まれます。

len

書き込むデータの最大バイト数(オプション)。0 より大きく、かつ data のサイズ以下でなければなりません。 デフォルトは data の長さです。

返り値

ラージオブジェクトに書き込んだバイト数を返します。 エラー時には FALSE を返します。

例 1. pg_lo_write() の例

<?php
   $doc_oid
= 189762345;
  
$data = "This will overwrite the start of the large object.";
  
$database = pg_connect("dbname=jacarta");
  
pg_query($database, "begin");
  
$handle = pg_lo_open($database, $doc_oid, "w");
  
$data = pg_lo_write($handle, $data);
  
pg_query($database, "commit");
?>



add a note add a note User Contributed Notes
pg_lo_write
nandrews at logictree dot co dot uk
06-Jun-2003 12:17
Using php 4.3.0 and PostgreSQL 7.3.1

I can write a simple script in which pg_lo_write seems to always return 1 and not the number of bytes written, as evidenced by extracting the data through another means.

Further more, I can make this pg_lo_write fail, or at least fail to write all the data it's pretty difficult to tell without the number of bytes written being returned, and not return the false value. In addition to this, the lo resource has been adjusted so that the oid it contains is 0.

Unfortunately, I do not know what exactly the failure mode is, it does seem to be in the ip network communication side of PostgreSQL, which is odd since the unix domain comms works fine for this. However, it would have been useful to have the pg_lo_write() function return as advertised, it would have saved some of the 2 man hours me and the dev. team put into diagnosing this problem.
cedric at isoca.com
27-Apr-2001 09:26
Be aware when you modify a lo with pg_lowrite() to remove first the old one : if the new lo is smaller than the one before, it only overwrite the begining and you keep the end of the old lo (open with "w" parameter, PHP 4.04 Linux RH).

<pg_lo_unlinkpg_meta_data" width="11" height="7"/>
 Last updated: Sun, 07 May 2006
show source | credits | sitemap | contact | advertising | mirror sites 
Copyright © 2001-2006 The PHP Group
All rights reserved.
This mirror generously provided by: PacketBusiness, Inc.
Last updated: Wed Jun 28 13:19:26 2006 JST