class LOB (View source)

A large object.

NOTE: Working with large objects requires an active transaction.

Constants

INVALID_OID

0, representing an invalid OID.

RW

Read/write mode.

Properties

Transaction read-only $transaction

The transaction wrapping the operations on the large object.

int read-only $oid

The OID of the large object.

resource read-only $stream

The stream connected to the large object.

Methods

__construct(Transaction $txn, int $oid = \pq\LOB::INVALID_OID, int $mode = \pq\LOB::RW)

Open or create a large object.

string
read(int $length = 0x1000, int $read = null)

Read a string of data from the current position of the large object.

int
seek(int $offset, int $whence = SEEK_SET)

Seek to a position within the large object.

int
tell()

Retrieve the current position within the large object.

truncate(int $length = 0)

Truncate the large object.

int
write(string $data)

Write data to the large object.

Details

__construct(Transaction $txn, int $oid = \pq\LOB::INVALID_OID, int $mode = \pq\LOB::RW)

Open or create a large object.

See pq\Transaction::openLOB() and pq\Transaction::createLOB().

Parameters

Transaction $txn

The transaction which wraps the large object operations.

int $oid

The OID of the existing large object to open.

int $mode

Access mode (read, write or read/write).

Exceptions

InvalidArgumentException
BadMethodCallException
RuntimeException

string read(int $length = 0x1000, int $read = null)

Read a string of data from the current position of the large object.

Parameters

int $length

The amount of bytes to read from the large object.

int $read

The amount of bytes actually read from the large object.

Return Value

string

the data read.

Exceptions

InvalidArgumentException
BadMethodCallException
RuntimeException

int seek(int $offset, int $whence = SEEK_SET)

Seek to a position within the large object.

Parameters

int $offset

The position to seek to.

int $whence

From where to seek (SEEK_SET, SEEK_CUR or SEEK_END).

Return Value

int

the new position.

Exceptions

InvalidArgumentException
BadMethodCallException
RuntimeException

int tell()

Retrieve the current position within the large object.

Return Value

int

the current position.

Exceptions

InvalidArgumentException
BadMethodCallException
RuntimeException

truncate(int $length = 0)

Truncate the large object.

Parameters

int $length

The length to truncate to.

Exceptions

InvalidArgumentException
BadMethodCallException
RuntimeException

int write(string $data)

Write data to the large object.

Parameters

string $data

The data that should be written to the current position.

Return Value

int

the number of bytes written.