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_write
Почист и полокален преглед на PHP референцата, со задржана структура од PHP.net и подобра читливост за примери, секции и белешки.
pg_lo_write
Референца за `function.pg-lo-write.php` со подобрена типографија и навигација.
pg_lo_write
(PHP 4 >= 4.2.0, PHP 5, PHP 7, PHP 8)
pg_lo_write — Пишувај во голем објект
= NULL
pg_lo_write() запишува податоци во голем објект на тековната позиција за барање.
За да се користи интерфејсот за големи објекти, неопходно е да се затвори во блок за трансакција.
Забелешка:
Оваа функција порано се нарекуваше pg_lowrite().
Параметри
lob-
Еден PgSql\Lob инстанца, вратена од pg_lo_open().
data-
Податоците што треба да се запишат во големиот објект. Ако
lengthе int и е помала од должината наdata, самоlengthбајти ќе бидат запишани. length-
Изборен максимален број на бајти за запишување. Мора да биде поголем од нула и не поголем од должината на
data. Стандардно е должината наdata.
Вратени вредности
Бројот на бајти запишани во големиот објект, или false при грешка.
Дневник на промени
| Верзија | = NULL |
|---|---|
| 8.1.0 |
На lob параметарот очекува PgSql\Lob
инстанца сега; претходно, а resource се очекуваше.
|
| 8.0.0 |
length сега е null.
|
Примери
Пример #1 pg_lo_write() example
<?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");
?>Белешки од корисници 2 забелешки
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.