PHP Conference Japan 2024

cubrid_lob2_read

(PECL CUBRID >= 8.4.1)

cubrid_lob2_read读取 BLOB/CLOB 数据

描述

cubrid_lob2_read(资源 $lob_identifier, 整数 $len): 字符串

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

参数

lob_identifier

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

len

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

返回值

返回内容作为字符串,当没有更多数据时返回 false,或在失败时返回 null

范例

示例 #1 cubrid_lob2_read() 示例 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
"当前位置是 " . cubrid_lob2_tell($row[1]) . "\n";

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

print
"\n向前移动后的位置是 " . cubrid_lob2_tell($row[1]) . "\n";

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

print
"\n读取后的位置是 " . cubrid_lob2_tell($row[1]) . "\n";

print
$data . "\n";

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

print
"\n再次移动后的位置是 " . cubrid_lob2_tell($row[1]) . "\n";

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

cubrid_disconnect($conn);
?>

示例 #2 cubrid_lob2_read() 示例 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
"没有更多数据\n";
break;
}
else {
print
"一定存在一些错误\n";
break;
}
}

cubrid_disconnect($conn);
?>

参见

添加注释

用户贡献笔记

此页面没有用户贡献的笔记。
To Top