Function to take a large object size:
<?php
function pg_lo_size ($lo) {
$pos = pg_lo_tell ($lo);
pg_lo_seek ($lo, 0, PGSQL_SEEK_END);
$size = pg_lo_tell ($lo);
pg_lo_seek ($lo, $pos, PGSQL_SEEK_SET);
return $size;
}
?>
(PHP 4 >= 4.2.0, PHP 5, PHP 7, PHP 8)
pg_lo_tell — 返回当前大型对象的指针位置
当前查找距离大对象开头的偏移量(字节数)。如果有错误,返回值为负。
示例 #1 pg_lo_tell() 示例
<?php
$doc_oid = 189762345;
$database = pg_connect("dbname=jacarta");
pg_query($database, "begin");
$handle = pg_lo_open($database, $doc_oid, "r");
// 忽略开始的 50000 字节
pg_lo_seek($handle, 50000, PGSQL_SEEK_SET);
// 查看忽略了多少
$offset = pg_lo_tell($handle);
echo "Seek position is: $offset";
pg_query($database, "commit");
?>
以上示例会输出:
Seek position is: 50000