PHP8 cubrid_lob2_read

2024-03-28 09:31 更新

(PECL CUBRID >= 8.4.1)

cubrid_lob2_read — 从 BLOB/CLOB 数据读取

说明

cubrid_lob2_read(resource $lob_identifier, int $len): string

cubrid_lob2_read() 函数从 LOB 数据并返回读取的字节数。len

参数 

lob_identifier

作为 cubrid_lob2_new() 结果的 Lob 标识符或从结果集中获取。

len

要从 lob 数据中读取的缓冲区的长度。

返回值 

以字符串形式返回内容,当没有更多数据时返回 false,失败时返回 null。

示例 

示例 #1 cubrid_lob2_read() example 1

<?php
// test_lob (id INT, contents CLOB)

$conn = cubrid_connect("localhost", 33000, "demodb", "public", "");

$req = cubrid_execute($conn, "select * from test_lob");

$row = cubrid_fetch_row($req, CUBRID_LOB);

print "position now is " . cubrid_lob2_tell($row[1]) . "\n";

cubrid_lob2_seek($row[1], 10, CUBRID_CURSOR_FIRST);

print "\nposition after moving farword is " . cubrid_lob2_tell($row[1]) . "\n";

$data = cubrid_lob2_read($row[1], 12);

print "\nposition after reading is " . cubrid_lob2_tell($row[1]) . "\n";

print $data . "\n";

cubrid_lob2_seek($row[1], 5, CUBRID_CURSOR_CURRENT);

print "\nposition after moving again is " . cubrid_lob2_tell($row[1]) . "\n";

$data = cubrid_lob2_read($row[1], 20);
print $data . "\n";

cubrid_disconnect($conn);
?>

示例 #2 cubrid_lob2_read() example 2

<?php
// test_lob (id INT, contents CLOB)

$conn = cubrid_connect("localhost", 33000, "demodb", "dba", "");

$req = cubrid_execute($conn, "select * from test_lob");

$row = cubrid_fetch_row($req, CUBRID_LOB);

while (true) {
    if ($data = cubrid_lob2_read($row[1], 1024)) {
        print $data . "\n";
    }
    elseif ($data === false) {
        print "There is no more data\n";
        break;
    }
    else {
        print "There must some errors\n";
        break;
    }
}

cubrid_disconnect($conn);
?>

参见 

  • cubrid_lob2_write() - 写入 lob 对象
  • cubrid_lob2_seek() - 移动 lob 对象的光标
  • cubrid_lob2_seek64() - 移动 lob 对象的光标
  • cubrid_lob2_tell() - 告知 LOB 对象的光标位置
  • cubrid_lob2_tell64() - 告知 LOB 对象的光标位置
  • cubrid_lob2_size() - 获取 lob 对象的大小
  • cubrid_lob2_size64() - 获取 lob 对象的大小


以上内容是否对您有帮助:
在线笔记
App下载
App下载

扫描二维码

下载编程狮App

公众号
微信公众号

编程狮公众号