PHP8 cubrid_lob2_write

2024-03-28 09:32 更新

(PECL CUBRID >= 8.4.1)

cubrid_lob2_write — 写入 lob 对象

说明

cubrid_lob2_write(resource $lob_identifier, string $buf): bool

cubrid_lob2_write() 函数读取的数据与数据一样多 from 并将其存储到 LOB 对象。请注意, 此函数现在只能附加字符。buf

参数 

lob_identifier

作为 cubrid_lob2_new() 结果的 Lob 标识符或从结果集中获取。

buf

需要写入 lob 对象的数据。

返回值 

成功时返回 true, 或者在失败时返回 false。

示例 

示例 #1 cubrid_lob2_write() 示例 1

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

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

cubrid_execute($conn,"DROP TABLE if exists test_lob");
cubrid_execute($conn,"CREATE TABLE test_lob (id INT, contents CLOB)");

$req = cubrid_prepare($conn, "INSERT INTO test_lob VALUES(2, ?)");

$lob = cubrid_lob2_new($conn, 'CLOB');
$len = cubrid_lob2_write($lob, "Hello world");

cubrid_lob2_bind($req, 1, $lob);
cubrid_execute($req);

cubrid_disconnect($conn);
?>

示例 #2 cubrid_lob2_write() example 2

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

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

cubrid_execute($conn,"DROP TABLE if exists test_lob");
cubrid_execute($conn,"CREATE TABLE test_lob (id INT, contents CLOB)");

$req = cubrid_prepare($conn, "INSERT INTO test_lob VALUES(1, ?)");
$lob1 = cubrid_lob2_new($conn, 'CLOB');
$len = cubrid_lob2_write($lob1, "cubrid php driver");
cubrid_lob2_bind($req, 1, $lob1);
cubrid_execute($req);

$req = cubrid_execute($conn, "select * from test_lob");

$row = cubrid_fetch_row($req, CUBRID_LOB);
$lob2 = $row[1];
cubrid_lob2_seek($lob2, 0, CUBRID_CURSOR_LAST);

$pos = cubrid_lob2_tell($lob2);
print "pos before write: $pos\n";

cubrid_lob2_write($lob2, "Hello world");

$pos = cubrid_lob2_tell($lob2);
print "pos after write: $pos\n";

cubrid_disconnect($conn);
?>

参见 

  • cubrid_lob2_read() - 从 BLOB/CLOB 数据读取
  • cubrid_lob2_seek() - 移动 lob 对象的光标
  • cubrid_lob2_seek64() - 移动 lob 对象的光标
  • cubrid_lob2_tell() - 告知 LOB 对象的光标位置
  • cubrid_lob2_tell64() - 告知 LOB 对象的光标位置
  • cubrid_lob2_size() - 获取 lob 对象的大小
  • cubrid_lob2_size64() - 获取 lob 对象的大小


以上内容是否对您有帮助:
在线笔记
App下载
App下载

扫描二维码

下载编程狮App

公众号
微信公众号

编程狮公众号