获取大对象大小的函数
<?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 "查找位置是:$offset";
pg_query($database, "commit");
?>
以上示例将输出
Seek position is: 50000