PHP 8.3.4 Released!

cubrid_lob2_write

(PECL CUBRID >= 8.4.1)

cubrid_lob2_writeEcrit dans un objet LOB

Description

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

La fonction cubrid_lob2_write() lit les données depuis le paramètre buf et les stocke dans l'objet LOB. Notez que cette fonction ne peut ajouter actuellement que des caractères.

Liste de paramètres

lob_identifier

Un identifiant LOB, récupéré depuis la fonction cubrid_lob2_new() ou depuis le jeu de résultats.

buf

Les données qui doivent être écrites dans l'objet LOB.

Valeurs de retour

Cette fonction retourne true en cas de succès ou false si une erreur survient.

Exemples

Exemple #1 Exemple 1 avec cubrid_lob2_write()

<?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);
?>

Exemple #2 Exemple 2 avec cubrid_lob2_write()

<?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
"Position après écriture : $pos\n";

cubrid_disconnect($conn);
?>

Voir aussi

add a note

User Contributed Notes

There are no user contributed notes for this page.
To Top