获取大型对象大小的函数
<?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