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