If you're not plausibly going to be storing more than 1GB of binary data in a single field, you might as well use the normal bytea type instead of LOBbing it.
They won't bloat the table as PostgreSQL would store the larger byte streams outside the table anyway (as Large Object storage does, only transparently) - including compressing them if it helps - while retaining all the binary string functions and operators.
PHP.mk документација
PDO::pgsqlLOBCreate
Почист и полокален преглед на PHP референцата, со задржана структура од PHP.net и подобра читливост за примери, секции и белешки.
Патека
pdo.pgsqllobcreate.php
Локална патека за оваа страница.
Извор
php.net/manual/en
Оригиналниот HTML се реупотребува и локално се стилизира.
Режим
Прокси + превод во позадина
Кодовите, табелите и белешките остануваат читливи во истиот тек.
Референца
pdo.pgsqllobcreate.php
PDO::pgsqlLOBCreate
Референца за `pdo.pgsqllobcreate.php` со подобрена типографија и навигација.
PDO::pgsqlLOBCreate
(PHP 5 >= 5.1.2, PHP 7, PHP 8, PECL pdo_pgsql >= 1.0.2)
PDO::pgsqlLOBCreate — Псевдоним на PDO::pgsqlLOBCreate()
Белешки од корисници 2 забелешки
Хејли Вотсон ¶
пред 7 години
stanislav dot perfilov at gmail dot com ¶
19 години пред
IMHO, there's a better way to handle the deletion of lob objects than the suggested here. The programmer can easily forget to unlink the lob. With the following trigger, no programmer actions are required.
By the way, one problem with bytea fields is that when you query the database, if you ask for that field, the data is actually retrieved. When you query for and oid, only the oid is retrieved and then you can open the lob whenever you want (if it's required).
CREATE OR REPLACE FUNCTION oidtable_after_update_delete()
RETURNS "trigger" AS
$BODY$
BEGIN
IF (TG_OP = 'UPDATE') THEN
IF (OLD.oidfield = NEW.oidfield) OR (OLD.oidfield IS NULL) THEN
RETURN NEW;
END IF;
END IF;
IF (EXISTS (SELECT 1 FROM pg_largeobject WHERE loid = OLD.oidfield)) THEN
PERFORM LO_UNLINK (OLD.oidfield);
END IF;
RETURN NEW;
END;
$BODY$
LANGUAGE 'plpgsql' VOLATILE;
CREATE TRIGGER oidtable_after_update_delete
AFTER UPDATE OR DELETE
ON oidtable
FOR EACH ROW
EXECUTE PROCEDURE oidtable_after_update_delete();