(PECL CUBRID >= 8.4.1)
cubrid_lob2_read — 从 BLOB/CLOB 数据中读取
cubrid_lob2_read() 函数从 LOB 数据中读取 len
个字节,并返回读取的字节。
示例 #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);
?>