pbms_read_stream
Description
string pbms_read_stream ( php_stream $input_stream, long $size [,string $table [,string $md5_digest [,resource $pbms]]]] )
Sends data to the PBMS BLOB streaming server returning a BLOB reference. The BLOB reference can then be inserted into a longblob column of a PBMS enabled table inplace of the actual BLOB data.

The caller provides an open stream from which the BLOB data to be sent is read. The stream can be any type of stream that supports the 'read' operation.

Parameters
$input_stream
A stream from which the BLOB data to be sent to the PBMS server is read. The stream must support the 'read' operation.
$size
The size of the BLOB being sent in bytes .
$table
The table into which the blob reference will eventually be inserted. If not supplied no table will be associated with the new BLOB until the reference is inserted into a table. Providing the table name here make the BLOB handling on the server a bit more efficient.
$md5_digest
A raw 16 byte MD5 digest of the BLOB being sent. If provided it will be used to verify that the data has been received correctly by the server.
$pbms
A valid PBMS connection resource. If $pbms is not specified, the last link opened by pbms_connect() is assumed. If no such link is found, it will try to create one as if pbms_connect() was called with no arguments. If by chance no connection is found or established, an E_WARNING level error is generated.
Return Values

Returns the PBMS BLOB reference for the BLOB data sent on success.

Returns FALSE on failure. Use pbms_errno() and pbms_error() to retrieve error details.

Example
<?php 
	pbms_connect();

	//-----------
	// Create a BLOB and insert it into a table.
	// Assume that the table exists.
	$fh = fopen("MyBLOB", "r");
	$blob_ref = pbms_read_stream($fh, filesize("MyBLOB"), "bobtest", md5_file("MyBLOB", true) );
	fclose($fh);
	
	query =  sprintf("insert into bobtest(id, name) Values(1, \"%s\")", $blob_ref);
	mysql_query($query);
	
	// Fetch the BLOB back again.
	$result =mysql_query("select name from bobtest where id = 1");
			
	$row = mysql_fetch_row($result);
	printf("NOTE: blob ref stored in table: \"%s\" is not the same as what was inserted \"%s\" \n", $row[0], $blob_ref)

	$fh = fopen("MyBLOB.out", "w+");
	pbms_write_stream($fh, $row[0]);
	fclose($fh);

	pbms_close();
?>
		
Related functions
pbms_put_data() pbms_get_data() pbms_write_stream()