Linux and UNIX Man Pages

Linux & Unix Commands - Search Man Pages

db2_lob_read(3) [php man page]

DB2_LOB_READ(3) 							 1							   DB2_LOB_READ(3)

db2_lob_read - Gets a user defined size of LOB files with each invocation

SYNOPSIS
string db2_lob_read (resource $stmt, int $colnum, int $length) DESCRIPTION
Use db2_lob_read(3) to iterate through a specified column of a result set and retrieve a user defined size of LOB data. PARAMETERS
o $stmt - A valid stmt resource containing LOB data. o $colnum - A valid column number in the result set of the stmt resource. o $length - The size of the LOB data to be retrieved from the stmt resource. RETURN VALUES
Returns the amount of data the user specifies. Returns FALSE if the data cannot be retrieved. EXAMPLES
Example #1 Iterating through different types of data <?php /* Database Connection Parameters */ $db = 'SAMPLE'; $username = 'db2inst1'; $password = 'ibmdb2'; /* Obtain Connection Resource */ $conn = db2_connect($db,$username,$password); if ($conn) { $drop = 'DROP TABLE clob_stream'; $result = @db2_exec( $conn, $drop ); $create = 'CREATE TABLE clob_stream (id INTEGER, my_clob CLOB)'; $result = db2_exec( $conn, $create ); $variable = ""; $stmt = db2_prepare($conn, "INSERT INTO clob_stream (id,my_clob) VALUES (1, ?)"); $variable = "THIS IS A CLOB TEST. THIS IS A CLOB TEST."; db2_bind_param($stmt, 1, "variable", DB2_PARAM_IN); db2_execute($stmt); $sql = "SELECT id,my_clob FROM clob_stream"; $result = db2_prepare($conn, $sql); db2_execute($result); db2_fetch_row($result); $i = 0; /* Read LOB data */ while ($data = db2_lob_read($result, 2, 6)) { echo "Loop $i: $data "; $i = $i + 1; } $drop = 'DROP TABLE blob_stream'; $result = @db2_exec( $conn, $drop ); $create = 'CREATE TABLE blob_stream (id INTEGER, my_blob CLOB)'; $result = db2_exec( $conn, $create ); $variable = ""; $stmt = db2_prepare($conn, "INSERT INTO blob_stream (id,my_blob) VALUES (1, ?)"); $variable = "THIS IS A BLOB TEST. THIS IS A BLOB TEST."; db2_bind_param($stmt, 1, "variable", DB2_PARAM_IN); db2_execute($stmt); $sql = "SELECT id,my_blob FROM blob_stream"; $result = db2_prepare($conn, $sql); db2_execute($result); db2_fetch_row($result); $i = 0; /* Read LOB data */ while ($data = db2_lob_read($result, 2, 6)) { echo "Loop $i: $data "; $i = $i + 1; } } else { echo 'no connection: ' . db2_conn_errormsg(); } ?> The above example will output: Loop 0: THIS I Loop 1: S A CL Loop 2: OB TES Loop 3: T. THI Loop 4: S IS A Loop 5: CLOB Loop 6: TEST. Loop 0: THIS I Loop 1: S A BL Loop 2: OB TES Loop 3: T. THI Loop 4: S IS A Loop 5: BLOB Loop 6: TEST. SEE ALSO
db2_bind_param(3), db2_exec(3), db2_execute(3), db2_fetch_row(3), db2_prepare(3), db2_result(3). PHP Documentation Group DB2_LOB_READ(3)

Check Out this Related Man Page

DB2_FETCH_OBJECT(3)							 1						       DB2_FETCH_OBJECT(3)

db2_fetch_object - Returns an object with properties representing columns in the fetched row

SYNOPSIS
object db2_fetch_object (resource $stmt, [int $row_number = -1]) DESCRIPTION
Returns an object in which each property represents a column returned in the row fetched from a result set. PARAMETERS
o $stmt - A valid stmt resource containing a result set. o $row_number - Requests a specific 1-indexed row from the result set. Passing this parameter results in a PHP warning if the result set uses a forward-only cursor. RETURN VALUES
Returns an object representing a single row in the result set. The properties of the object map to the names of the columns in the result set. The IBM DB2, Cloudscape, and Apache Derby database servers typically fold column names to upper-case, so the object properties will reflect that case. If your SELECT statement calls a scalar function to modify the value of a column, the database servers return the column number as the name of the column in the result set. If you prefer a more descriptive column name and object property, you can use the AS clause to assign a name to the column in the result set. Returns FALSE if no row was retrieved. EXAMPLES
Example #1 A db2_fetch_object(3) example The following example issues a SELECT statement with a scalar function, RTRIM, that removes whitespace from the end of the column. Rather than creating an object with the properties "BREED" and "2", we use the AS clause in the SELECT statement to assign the name "name" to the modified column. The database server folds the column names to upper-case, resulting in an object with the properties "BREED" and "NAME". <?php $conn = db2_connect($database, $user, $password); $sql = "SELECT breed, RTRIM(name) AS name FROM animals WHERE id = ?"; if ($conn) { $stmt = db2_prepare($conn, $sql); db2_execute($stmt, array(0)); while ($pet = db2_fetch_object($stmt)) { echo "Come here, {$pet->NAME}, my little {$pet->BREED}!"; } db2_close($conn); } ?> The above example will output: Come here, Pook, my little cat! SEE ALSO
db2_fetch_array(3), db2_fetch_assoc(3), db2_fetch_both(3), db2_fetch_row(3), db2_result(3). PHP Documentation Group DB2_FETCH_OBJECT(3)
Man Page