pg_lo_write

(PHP 4 >= 4.2.0, PHP 5, PHP 7, PHP 8)

pg_lo_write向大型对象写入数据

说明

pg_lo_write ( resource $large_object , string $data ) : int

pg_lo_write()data 参数中的数据尽可能多地写入大型对象并返回实际写入的字节数。如果出错则返回 falselarge_object 参数是 pg_lo_open() 函数所返回的大型对象资源号。

要使用大型对象(lo)接口,需要将其放置在事务块中。

Note:

本函数以前的名字为 pg_lo_write()

参见 pg_lo_create()pg_lo_open()

User Contributed Notes

nandrews at logictree dot co dot uk 05-Jun-2003 08: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 05: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).
PHP8中文手册 站长在线 整理 版权归PHP文档组所有