PHP Doku:: Schreibt in ein Large Object - function.pg-lo-write.html

Verlauf / Chronik / History: (1) anzeigen

Sie sind hier:
Doku-StartseitePHP-HandbuchFunktionsreferenzDatenbankerweiterungenAnbieterspezifische DatenbankerweiterungenPostgreSQLPostgreSQL-Funktionenpg_lo_write

Ein Service von Reinhard Neidl - Webprogrammierung.

PostgreSQL-Funktionen

<<pg_lo_unlink

pg_meta_data>>

pg_lo_write

(PHP 4 >= 4.2.0, PHP 5)

pg_lo_writeSchreibt in ein Large Object

Beschreibung

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

pg_lo_write() schreibt Daten ab der aktuellen Position der internen Schreib-Lese-Marke in ein Large Object.

Um die Large Object (lo) Schnittstelle benutzen zu können, müssen die Kommandos innerhalb einer Transaktion ausgeführt werden.

Hinweis:

Diese Funktion ersetzt die Funktion pg_lowrite()().

Parameter-Liste

large_object

PostgreSQL Large Object Ressource (LOB), die von der Funktion pg_lo_open() zurückgegeben wurde.

data

Die Daten, die in das Large Object geschrieben werden. Falls len angegeben wurde und kleiner als die Länge von data ist, werden nur len Bytes geschrieben.

len

Die maximale Anzahl der Bytes, die geschrieben werden. Die Anzahl muss größer als 0 und kleiner als die Länge von data sein. Der Vorgabewert ist die Länge von data. Diese Angabe ist optional.

Rückgabewerte

Die Anzahl der Bytes, die in das Large Object geschrieben wurden oder FALSE, falls ein Fehler auftrat.

Beispiele

Beispiel #1 pg_lo_write()-Beispiel

<?php
   $doc_oid 
189762345;
   
$data "Hiermit wird der Anfang des Large Objects überschrieben.";
   
$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");
?>

Siehe auch


2 BenutzerBeiträge:
- Beiträge aktualisieren...
nandrews at logictree dot co dot uk
5.06.2003 17: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.04.2001 14: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).



PHP Powered Diese Seite bei php.net
The PHP manual text and comments are covered by the Creative Commons Attribution 3.0 License © the PHP Documentation Group - Impressum - mail("TO:Reinhard Neidl",...)