php8.5
Home/ Manual/ pgsql / functions/ pg_lo_create

pg_lo_create

PHP function Edit on GitHub ✎

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

Create a large object

Description

pg_lo_create([PgSql\Connection $connection], [mixed $object_id]): int
pg_lo_create(mixed $object_id): int

pg_lo_create() creates a large object and returns the OID of the large object. PostgreSQL access modes INV_READ and INV_WRITE are not supported, the object is created always with both read and write access.

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

Instead of using the large object interface (which has no access controls and is cumbersome to use), try PostgreSQL's bytea column type and pg_escape_bytea().

Note

This function used to be called pg_locreate().

Parameters

connection

Connection-with-unspecified-default

object_id

If an object_id is given the function will try to create a large object with this id, else a free object id is assigned by the server.

Return Values

A large object OID, Falseforfailure.

Changelog

VersionDescription

Examples

pg_lo_create() example

php
<?php
   $database = pg_connect("dbname=jacarta");
   pg_query($database, "begin");
   $oid = pg_lo_create($database);
   echo "$oid\n";
   $handle = pg_lo_open($database, $oid, "w");
   echo "$handle\n";
   pg_lo_write($handle, "large object data");
   pg_lo_close($handle);
   pg_query($database, "commit");
?>

Source: reference/pgsql/functions/pg-lo-create.xml · from the official PHP manual (php/doc-en)