PHP8 cubrid_lob2_export

2024-03-28 09:31 更新
(PECL CUBRID >= 8.4.1)

cubrid_lob2_export — 將 lob 對(duì)象導(dǎo)出到文件

說(shuō)明

cubrid_lob2_export(resource $lob_identifier, string $file_name): bool

cubrid_lob2_export() 函數(shù)用于保存 BLOB/CLOB 數(shù)據(jù)的內(nèi)容添加到文件中。要使用此函數(shù),您必須使用 cubrid_lob2_new() 或從 CUBRID 獲取 lob 對(duì)象 數(shù)據(jù)庫(kù)優(yōu)先。如果文件已存在,則操作將失敗。 此函數(shù)不會(huì)影響 lob 對(duì)象的光標(biāo)位置。 它操作整個(gè) lob 對(duì)象。

參數(shù) 

lob_identifier

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

filename

要存儲(chǔ) BLOB/CLOB 數(shù)據(jù)的文件名。它還支持文件的路徑。

返回值

成功時(shí)返回 true, 或者在失敗時(shí)返回 false。

示例 

示例 #1 cubrid_lob2_export() example

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

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

cubrid_execute($conn,"DROP TABLE if exists doc");
cubrid_execute($conn,"CREATE TABLE doc (id INT, doc_content CLOB)");
cubrid_execute($conn,"INSERT INTO doc VALUES (5,'hello,cubrid')");

$req = cubrid_prepare($conn, "select * from doc");

cubrid_execute($req);

cubrid_move_cursor($req, 1, CUBRID_CURSOR_FIRST);

$row = cubrid_fetch($req, CUBRID_NUM | CUBRID_LOB);

cubrid_lob2_export($row[1], "doc_3.txt");

cubrid_lob2_close($row[1]);
cubrid_disconnect($conn);
?>

參見(jiàn) 

  • cubrid_lob2_new() - 創(chuàng)建一個(gè) lob 對(duì)象
  • cubrid_lob2_close() - 關(guān)閉 LOB 對(duì)象
  • cubrid_lob2_import() - 從文件導(dǎo)入 BLOB/CLOB 數(shù)據(jù)
  • cubrid_lob2_bind() - 將 lob 對(duì)象或字符串作為 lob 對(duì)象綁定到作為參數(shù)的預(yù)準(zhǔn)備語(yǔ)句


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

掃描二維碼

下載編程獅App

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

編程獅公眾號(hào)