Firebird 2.0
PHP5 Programming
Manual

FBIRD_BLOB_INFO

Purpose

Use the fbird_blob_info function to retrieve information about a blob.

Syntax

<blob_info> ::=
   fbird_blob_info( [conn_hndl ,] blob_id )


Element 
Type
Description
conn_hndl
resource
A valid connection handle
blob_id
string
A valid blob id
<return>
mixed
Array upon success, False upon failure

Semantics

The fbird_blob_info function returns an array with 4 elements, containing information about a blob. The function returns False on failure.

The information returned upon success consists of:

Element 
Type
Description
[0]
int
Total blob length
[1]
int
Number of segments
[2]
int
Size of largest segment
[3]
bool
True if a stream blob

The information returnd by this function is particularly usefull when retrieving a segmented blob.

If a connection handle is not provided, then the "default" connection will be used. The default connection is assigned every time you call fbird_connect or fbird_pconnect, so if you have multiple connections it will be whichever one was connected last.

Example

The below example retrieves a segmented blob piece by piece and sends the full result to the browser:

$row = ibase_fetch_row($result);
$blobinfo = ibase_blob_info($row[0]);
$blob_hndl = ibase_blob_open($row[0]);
$seg_size = $blobinfo[2];
while( $i < $blobinfo[1]){
$totalimage .= ibase_blob_get($blob_hndl, $seg_size);
   $i += $seg_size;
}
ibase_blob_close($blob_hndl);
echo $totalimage;


The following example fetches a blob in one big fetch and sends the result to the browsers:

$row = ibase_fetch_row($result);
$blobinfo  = ibase_blob_info($row[0]);
$blob_hndl = ibase_blob_open($row[0]);
$image     = ibase_blob_get($blob_hndl, $blobinfo[0]);
ibase_blob_close($blob_hndl);
echo $totalimage;



See also

fbird_blob_get, fbird_blob_open, fbird_blob_close


previous page goto index next page

Legal information