• « Pdo\Pgsql::lobOpen
  • Pdo\Pgsql::setNoticeCallback »
  • PHP Manual
  • Pdo\Pgsql
  • Deletes the large object

Pdo\Pgsql::lobUnlink

(PHP 8 >= 8.4.0)

Pdo\Pgsql::lobUnlink — Deletes the large object

说明

public function Pdo\Pgsql::lobUnlink(string $oid): bool

Deletes a large object from the database identified by OID.

注意: This function, and all manipulations of the large object, must be called and carried out within a transaction.

参数

oid
A large object identifier.

返回值

成功时返回 true, 或者在失败时返回 false。

示例

示例 #1 Pdo\Pgsql::lobUnlink() example

This example unlinks a large object from the database before deleting the row that references it. It uses the blobs table from the Pdo\Pgsql::lobCreate() and Pdo\Pgsql::lobOpen() examples.

<?php
$db = new Pdo\Pgsql('pgsql:dbname=test host=localhost', $user, $pass);
$db->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
$db->beginTransaction();
$db->lobUnlink($oid);
$stmt = $db->prepare("DELETE FROM BLOBS where ident = ?");
$stmt->execute([$some_id]);
$db->commit();
?>

参见

  • Pdo\Pgsql::lobCreate() - Creates a new large object
  • Pdo\Pgsql::lobOpen() - Opens an existing large object stream
  • pg_lo_create() - 新建大对象
  • pg_lo_open() - 打开大对象
↑ and ↓ to navigate • Enter to select • Esc to close • / to open