Dutch PHP Conference 2023 - Call for Papers


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

pg_lo_writeEscreve em um objeto grande (large object)


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

pg_lo_write() escreve em um objeto grande (large object) a partir de uma variável data e retorna o número de bytes escritos, ou false em caso de erro. large_object é um recurso (resource) de objeto grande criado a partir de pg_lo_open().

Para usar a interface de objetos grandes (lo) é necessário encapsulá-lo em um bloco de transação.


Esta função era chamada pg_lowrite().

Veja também pg_lo_create() e pg_lo_open().

add a note

User Contributed Notes 2 notes

cedric at isoca.com
22 years ago
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).
nandrews at logictree dot co dot uk
19 years ago
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.
To Top