PHP: pg_lo_write - Manual

downloads | documentation | faq | getting help | mailing lists | reporting bugs | php.net sites | links | conferences | my php.net

search for in the

pg_meta_data pg_lo_unlink

Last updated: Sat, 27 Jan 2007

view this page in

# pg_lo_write

(PHP 4 >= 4.2.0, PHP 5)

pg_lo_write -- Write to a large object

## Описание

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

pg_lo_write() writes data into a large object at the current seek position.

To use the large object interface, it is necessary to enclose it within a transaction block.

> Замечание: This function used to be called pg_lowrite().

## Список параметров

`large_object`

  PostgreSQL large object (LOB) resource, returned by pg_lo_open().

`data`

  The data to be written to the large object. If `len` is specified and is less than the length of `data`, only `len` bytes will be written.

`len`

  An optional maximum number of bytes to write. Must be greater than zero and no greater than the length of `data`. Defaults to the length of `data`.

## Возвращаемые значения

The number of bytes written to the large object, or `FALSE` on error.

## Примеры

Пример 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");
?>`

## Смотрите также

pg_lo_create()
pg_lo_open()

add a note User Contributed Notes
pg_lo_write
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).`
add a note
pg_meta_data pg_lo_unlink

Last updated: Sat, 27 Jan 2007
show source | credits | stats | sitemap | contact | advertising | mirror sites
Copyright © 2001-2007 The PHP Group
All rights reserved.
This mirror generously provided by: Yahoo! Inc.
Last updated: Sat Mar 10 10:36:09 2007 PST