函式名稱:cubrid_lob2_tell()
功能:獲取CUBRID LOB物件的當前位置指標位置。
用法:int cubrid_lob2_tell(resource $lob_identifier)
引數:
- $lob_identifier:CUBRID LOB物件識別符號,是透過cubrid_lob2_new()或cubrid_connect()等函式返回的LOB物件。
返回值: 返回值為目前位置指標在 CUBRID LOB 物件中的偏移。如果發生錯誤或無效的 LOB 物件識別符號,返回 FALSE。
示例:
<?php
$conn = cubrid_connect("localhost", 33000, "demodb", "dba", "");
$lob_identifier = cubrid_lob2_new($conn);
cubrid_lob2_write($lob_identifier, "This is a sample text.", 19);
// 獲取當前位置指標的位置
$position = cubrid_lob2_tell($lob_identifier);
if ($position !== false) {
echo "當前位置指標的位置為:" . $position;
} else {
echo "獲取位置指標位置失敗";
}
cubrid_lob2_close($lob_identifier);
cubrid_disconnect($conn);
?>
輸出: 當前位置指標的位置為:19
說明: 以上示例首先連線到CUBRID資料庫,並建立一個LOB物件,然後使用cubrid_lob2_write()函式將一段文字寫入LOB物件中。接著,使用cubrid_lob2_tell()函式獲取當前位置指標的位置,並將其輸出。最後,關閉LOB物件和資料庫連線。
注意事項:
- 使用該函式前,需要確保已連線到CUBRID資料庫並擁有有效的LOB物件識別符號。
- cubrid_lob2_tell()函式僅適用於CUBRID資料庫。
- 在讀取或寫入LOB物件之前必須先設定當前位置指標的位置。