PHP8 cubrid_lob2_read

2024-03-28 09:31 更新

(PECL CUBRID >= 8.4.1)

cubrid_lob2_read — 從 BLOB/CLOB 數(shù)據(jù)讀取

說(shuō)明

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

cubrid_lob2_read() 函數(shù)從 LOB 數(shù)據(jù)并返回讀取的字節(jié)數(shù)。len

參數(shù) 

lob_identifier

作為 cubrid_lob2_new() 結(jié)果的 Lob 標(biāo)識(shí)符或從結(jié)果集中獲取。

len

要從 lob 數(shù)據(jù)中讀取的緩沖區(qū)的長(zhǎng)度。

返回值 

以字符串形式返回內(nèi)容,當(dāng)沒(méi)有更多數(shù)據(jù)時(shí)返回 false,失敗時(shí)返回 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);
?>

參見(jiàn) 

  • cubrid_lob2_write() - 寫(xiě)入 lob 對(duì)象
  • cubrid_lob2_seek() - 移動(dòng) lob 對(duì)象的光標(biāo)
  • cubrid_lob2_seek64() - 移動(dòng) lob 對(duì)象的光標(biāo)
  • cubrid_lob2_tell() - 告知 LOB 對(duì)象的光標(biāo)位置
  • cubrid_lob2_tell64() - 告知 LOB 對(duì)象的光標(biāo)位置
  • cubrid_lob2_size() - 獲取 lob 對(duì)象的大小
  • cubrid_lob2_size64() - 獲取 lob 對(duì)象的大小


以上內(nèi)容是否對(duì)您有幫助:
在線筆記
App下載
App下載

掃描二維碼

下載編程獅App

公眾號(hào)
微信公眾號(hào)

編程獅公眾號(hào)